]> Creatis software - crea.git/blob - cmake/CREAMacro_FindAndUseLibraries.cmake
*** empty log message ***
[crea.git] / cmake / CREAMacro_FindAndUseLibraries.cmake
1
2
3 MACRO(CREA_FIND_AND_USE_LIBRARIES)
4
5 #-----------------------------------------------------------------------------
6 IF(USE_VTK)
7   INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseVTK.cmake)
8   CREA_FIND_AND_USE_VTK()  
9 ENDIF(USE_VTK)
10 #-----------------------------------------------------------------------------
11
12 #-----------------------------------------------------------------------------
13 IF(USE_KWWIDGETS)
14   IF(NOT KWWidgets_FOUND)
15     # Search KWWidgets
16     FIND_PACKAGE(KWWidgets)
17     # If found
18     IF(KWWidgets_FOUND)
19       MESSAGE ( STATUS "=======================================")
20       MESSAGE ( STATUS "Looking for KWWidgets... found")
21       MESSAGE ( STATUS "* Dir     = ${KWWidgets_DIR}")
22       MESSAGE ( STATUS "* Version = ${KWWidgets_MAJOR_VERSION}.${KWWidgets_MINOR_VERSION}.${KWWidgets_BUILD_VERSION}")
23       IF (USE_VTK)
24          # KWWidgets must not search again for vtk !
25         SET(KWWidgets_NO_USE_VTK ON)
26       ENDIF (USE_VTK)
27
28       INCLUDE(${KWWidgets_USE_FILE})
29       CREA_DEFINE( USE_KWWIDGETS )
30       SET(KWWIDGETS_LIBRARIES
31         ${KWWidgets_LIBRARIES}
32         ) 
33       MARK_AS_ADVANCED(KWWidgets_DIR)
34     ELSE(KWWidgets_FOUND)
35       message(FATAL_ERROR "KWWidgets_DIR not found")
36     ENDIF(KWWidgets_FOUND)
37   ENDIF(NOT KWWidgets_FOUND)
38 ENDIF(USE_KWWIDGETS)
39 #-----------------------------------------------------------------------------
40
41
42
43 #-----------------------------------------------------------------------------
44 IF(USE_ITK)
45   IF(NOT ITK_FOUND)
46     # Search ITK
47     FIND_PACKAGE(ITK)
48     # If itk found
49     IF(ITK_FOUND)
50       MESSAGE ( STATUS "=======================================")
51       MESSAGE ( STATUS "Looking for ITK... found")
52       MESSAGE ( STATUS "* Dir     = ${ITK_DIR}")
53       MESSAGE ( STATUS "* Version = ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}")
54       INCLUDE(${ITK_USE_FILE})
55       CREA_DEFINE( USE_ITK )
56       CREA_DEFINE( _USE_ITK_ )
57       SET(ITK_LIBRARIES
58         ITKCommon ITKIO ITKBasicFilters ITKAlgorithms
59         )  
60       MARK_AS_ADVANCED(ITK_DIR)
61     ELSE(ITK_FOUND)
62       message(FATAL_ERROR "ITK_DIR not found")
63     ENDIF(ITK_FOUND)
64   ENDIF(NOT ITK_FOUND)
65 ENDIF(USE_ITK)
66 #-----------------------------------------------------------------------------
67
68
69 #-----------------------------------------------------------------------------
70 IF(USE_GDCM)
71   IF (USE_GDCM2)
72     MESSAGE(ERROR "CANNOT USE BOTH gdcm AND gdcm2 !")
73   ENDIF (USE_GDCM2)
74
75   IF(NOT GDCM_FOUND)
76     # Search GDCM
77     FIND_PACKAGE(GDCM)
78     # If gdcm found
79     IF(GDCM_FOUND)
80       INCLUDE(${GDCM_USE_FILE})
81       CREA_DEFINE( USE_GDCM )
82       
83       MESSAGE ( STATUS "=======================================")
84       MESSAGE ( STATUS "Looking for GDCM... found")
85       MESSAGE ( STATUS "* Dir       = ${GDCM_DIR}")
86       MESSAGE ( STATUS "* Version   = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
87       MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}")
88       
89       # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with 
90       # embedded gdcm in ITK and will result in hard seg faults !
91       IF(USE_ITK)
92         IF (GDCM_NAME_SPACE STREQUAL "gdcm")
93           MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value")
94         ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm")
95       ENDIF(USE_ITK)
96       
97       MARK_AS_ADVANCED(GDCM_DIR)
98       
99       SET(GDCM_LIBRARIES
100         ${GDCM_LIBRARIES} 
101         )
102       
103       # TODO : Test that GDCM was built with option "vtkgdcm"
104       IF(USE_GDCM_VTK)
105         IF(USE_VTK)
106           SET(GDCM_LIBRARIES
107             ${GDCM_LIBRARIES}
108             vtkgdcm  
109             )
110         ENDIF(USE_VTK)
111       ENDIF(USE_GDCM_VTK)
112       
113     ENDIF(GDCM_FOUND)
114   ENDIF(NOT GDCM_FOUND)
115 ENDIF(USE_GDCM)
116
117 #-----------------------------------------------------------------------------
118
119 #-----------------------------------------------------------------------------
120 IF(USE_GDCM2)
121   IF(NOT GDCM_FOUND)
122     # Search GDCM2
123     FIND_PACKAGE(GDCM)
124     # If gdcm found
125     IF(GDCM_FOUND)
126       INCLUDE(${GDCM_USE_FILE})
127       
128       IF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
129         MESSAGE(FATAL_ERROR "gdcm version 2 needed. found ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}. Set GDCM_DIR to the gdcm version 2 directory")
130       ENDIF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
131       
132       CREA_DEFINE( USE_GDCM2 )
133       CREA_DEFINE_WITH_VAL( GDCM_NAME_SPACE gdcm )
134       
135       MESSAGE ( STATUS "=======================================")
136       MESSAGE ( STATUS "Looking for GDCM2... found")
137       MESSAGE ( STATUS "* Dir       = ${GDCM_DIR}")
138       MESSAGE ( STATUS "* Version   = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
139       MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}")
140       
141       # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with 
142       # embedded gdcm in ITK and will result in hard seg faults !
143       IF(USE_ITK)
144         IF (GDCM_NAME_SPACE STREQUAL "gdcm")
145           MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value")
146         ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm")
147       ENDIF(USE_ITK)
148       
149       MARK_AS_ADVANCED(GDCM_DIR)
150       
151       SET(GDCM_LIBRARIES
152         ${GDCM_LIBRARIES} 
153         )
154       
155       # TODO : Test that GDCM was built with option "vtkgdcm"
156       IF(USE_GDCM_VTK)
157         IF(USE_VTK)
158           SET(GDCM_LIBRARIES
159             ${GDCM_LIBRARIES}
160             vtkgdcm  
161             )
162         ENDIF(USE_VTK)
163       ENDIF(USE_GDCM_VTK)
164       
165     ENDIF(GDCM_FOUND)
166   ENDIF(NOT GDCM_FOUND)
167 ENDIF(USE_GDCM2)
168
169 #-----------------------------------------------------------------------------
170
171 #-----------------------------------------------------------------------------
172 IF(USE_WXWIDGETS)
173   IF(NOT wxWidgets_FOUND)
174     INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseWxWidgets.cmake)
175     CREA_FIND_WXWIDGETS()
176     CREA_USE_WXWIDGETS()
177   ENDIF(NOT wxWidgets_FOUND)
178 ENDIF(USE_WXWIDGETS)
179 #-----------------------------------------------------------------------------
180
181
182
183 #-----------------------------------------------------------------------------
184 IF(USE_DOXYGEN) 
185   IF(NOT DOXYGEN)
186     MESSAGE ( STATUS "=======================================")
187     FIND_PACKAGE(Doxygen REQUIRED)
188     #  MESSAGE(STATUS "Looking for doxygen... - found ${DOXYGEN}")
189     #  IF(DOXYGEN)
190     #    
191     #  ELSE(DOXYGEN)
192     #    MESSAGE(FATAL_ERROR "Doxygen not found. Required to build the doxygen documentation")
193   ENDIF(NOT DOXYGEN)
194 ENDIF(USE_DOXYGEN)
195 #-----------------------------------------------------------------------------
196
197
198 #-----------------------------------------------------------------------------
199 IF(USE_LATEX) 
200   IF (NOT LATEX_COMPILER)
201     FIND_PACKAGE(LATEX REQUIRED)
202     MESSAGE ( STATUS "=======================================")
203     MESSAGE(STATUS "Looking for latex... - found ${LATEX_COMPILER}")
204   ENDIF (NOT LATEX_COMPILER)
205 ENDIF(USE_LATEX) 
206 #-----------------------------------------------------------------------------
207
208 #-----------------------------------------------------------------------------
209 IF(USE_TTH) 
210   IF (NOT TTH_EXECUTABLE)
211     FIND_FILE( TTH_EXECUTABLE NAME tth tth.exe PATHS . $ENV{CREATIS}/tth_exe/ ~/Creatis/tth ~/Creatis/tth_linux)
212     IF (NOT TTH_EXECUTABLE)
213       MESSAGE(FATAL_ERROR "TTH not found (LATEX_tth_CONVERTER). Required to build the HTML documentation from tex source")
214     ELSE (NOT  TTH_EXECUTABLE)
215       MESSAGE ( STATUS "=======================================")
216       MESSAGE ( STATUS "Looking for tth... - found ${TTH_EXECUTABLE}")
217     ENDIF(NOT TTH_EXECUTABLE)
218     MARK_AS_ADVANCED( TTH_EXECUTABLE )
219   ENDIF(NOT TTH_EXECUTABLE)
220 ENDIF(USE_TTH)
221 #-----------------------------------------------------------------------------
222
223 #-----------------------------------------------------------------------------
224 IF(USE_BOOST)
225   IF(NOT Boost_FOUND)
226     FIND_PACKAGE(Boost REQUIRED)
227     IF(Boost_FOUND)
228       MESSAGE ( STATUS "=======================================")
229       MESSAGE ( STATUS "Looking for boost C++ library... - found in ${Boost_INCLUDE_DIR}")
230       INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
231       LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} )
232       CREA_DEFINE( USE_BOOST )
233       IF(NOT WIN32)
234         SET(BOOST_LIBRARIES
235           boost_signals
236           boost_filesystem
237           )
238       ENDIF(NOT WIN32)
239       MARK_AS_ADVANCED(Boost_INCLUDE_DIR)
240     ELSE(Boost_FOUND)
241       MESSAGE(FATAL_ERROR "boost C++ library not found - Set Boost_INCLUDE_DIR to the directory containing boost headers")
242     ENDIF(Boost_FOUND)
243   ENDIF(NOT Boost_FOUND)
244 ENDIF(USE_BOOST)
245 #-----------------------------------------------------------------------------
246
247
248 ENDMACRO(CREA_FIND_AND_USE_LIBRARIES)