]> 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 one can invoke this macro then crea has already been found !!
7 # However if one whishes to link against crea and crea was built 
8 # with wx or vtk then we have to find them.
9 # This USE_CREA var is made to resolve this dependency.
10 IF(USE_CREA)
11   IF(CREA_BUILT_WITH_WX)
12     SET(USE_WXWIDGETS ON)
13   ENDIF(CREA_BUILT_WITH_WX)
14   IF(CREA_BUILT_WITH_VTK)
15     SET(USE_VTK ON)
16   ENDIF(CREA_BUILT_WITH_VTK)
17 ENDIF(USE_CREA)
18 #-----------------------------------------------------------------------------
19
20
21 #-----------------------------------------------------------------------------
22 IF(USE_QT4)
23   IF(NOT QT_FOUND)
24     FIND_PACKAGE(Qt4 REQUIRED)
25     IF(QT_FOUND)
26       MESSAGE ( STATUS "=======================================")
27       MESSAGE ( STATUS "Looking for QT4... found")
28       MESSAGE ( STATUS "* Inc Dir = ${QT_INCLUDE_DIR}")
29       MESSAGE ( STATUS "* Version = ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
30       INCLUDE(${QT_USE_FILE})
31       CREA_DEFINE( USE_QT )
32     #    SET(QT_LIBRARIES
33     #      ${QT_LIBRARIES}
34     #      ) 
35     #  MARK_AS_ADVANCED(Qt4_DIR)
36    ENDIF(QT_FOUND)
37   ENDIF(NOT QT_FOUND)
38 ENDIF(USE_QT4)
39 #-----------------------------------------------------------------------------
40
41 #-----------------------------------------------------------------------------
42 IF(USE_VTK)
43   INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseVTK.cmake)
44   CREA_FIND_AND_USE_VTK()  
45 ENDIF(USE_VTK)
46 #-----------------------------------------------------------------------------
47
48 #-----------------------------------------------------------------------------
49 IF(USE_KWWIDGETS)
50   IF(NOT KWWidgets_FOUND)
51     # Search KWWidgets
52     FIND_PACKAGE(KWWidgets)
53     # If found
54     IF(KWWidgets_FOUND)
55       MESSAGE ( STATUS "=======================================")
56       MESSAGE ( STATUS "Looking for KWWidgets... found")
57       MESSAGE ( STATUS "* Dir     = ${KWWidgets_DIR}")
58       MESSAGE ( STATUS "* Version = ${KWWidgets_MAJOR_VERSION}.${KWWidgets_MINOR_VERSION}.${KWWidgets_BUILD_VERSION}")
59       IF (USE_VTK)
60          # KWWidgets must not search again for vtk !
61         SET(KWWidgets_NO_USE_VTK ON)
62       ENDIF (USE_VTK)
63
64       INCLUDE(${KWWidgets_USE_FILE})
65       CREA_DEFINE( USE_KWWIDGETS )
66       SET(KWWIDGETS_LIBRARIES
67         ${KWWidgets_LIBRARIES}
68         ) 
69       MARK_AS_ADVANCED(KWWidgets_DIR)
70     ELSE(KWWidgets_FOUND)
71       message(FATAL_ERROR "KWWidgets_DIR not found")
72     ENDIF(KWWidgets_FOUND)
73   ENDIF(NOT KWWidgets_FOUND)
74 ENDIF(USE_KWWIDGETS)
75 #-----------------------------------------------------------------------------
76
77
78
79 #-----------------------------------------------------------------------------
80 IF(USE_ITK)
81   IF(NOT ITK_FOUND)
82     # Search ITK
83     FIND_PACKAGE(ITK)
84     # If itk found
85     IF(ITK_FOUND)
86       MESSAGE ( STATUS "=======================================")
87       MESSAGE ( STATUS "Looking for ITK... found")
88       MESSAGE ( STATUS "* Dir     = ${ITK_DIR}")
89       MESSAGE ( STATUS "* Version = ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}")
90       SET(SKIP_ITK_BUILD_SETTINGS_FILE ON)
91       INCLUDE(${ITK_USE_FILE})
92       CREA_DEFINE( USE_ITK )
93       CREA_DEFINE( _USE_ITK_ )
94       SET(ITK_LIBRARIES
95         ITKCommon ITKIO ITKBasicFilters ITKAlgorithms
96         )  
97       MARK_AS_ADVANCED(ITK_DIR)
98     ELSE(ITK_FOUND)
99       message(FATAL_ERROR "ITK_DIR not found")
100     ENDIF(ITK_FOUND)
101   ENDIF(NOT ITK_FOUND)
102 ENDIF(USE_ITK)
103 #-----------------------------------------------------------------------------
104
105
106 #-----------------------------------------------------------------------------
107 IF(USE_GDCM)
108   IF (USE_GDCM2)
109     MESSAGE(ERROR "CANNOT USE BOTH gdcm AND gdcm2 !")
110   ENDIF (USE_GDCM2)
111
112   IF(NOT GDCM_FOUND)
113     # Search GDCM
114     FIND_PACKAGE(GDCM)
115     # If gdcm found
116     IF(GDCM_FOUND)
117       INCLUDE(${GDCM_USE_FILE})
118       CREA_DEFINE( USE_GDCM )
119       
120       MESSAGE ( STATUS "=======================================")
121       MESSAGE ( STATUS "Looking for GDCM... found")
122       MESSAGE ( STATUS "* Dir       = ${GDCM_DIR}")
123       MESSAGE ( STATUS "* Version   = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
124       MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}")
125       
126       # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with 
127       # embedded gdcm in ITK and will result in hard seg faults !
128       IF(USE_ITK)
129         IF (GDCM_NAME_SPACE STREQUAL "gdcm")
130           MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value")
131         ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm")
132       ENDIF(USE_ITK)
133       
134       MARK_AS_ADVANCED(GDCM_DIR)
135       
136       SET(GDCM_LIBRARIES
137         ${GDCM_LIBRARIES} 
138         )
139       
140       # TODO : Test that GDCM was built with option "vtkgdcm"
141       IF(USE_GDCM_VTK)
142         IF(USE_VTK)
143           SET(GDCM_LIBRARIES
144             ${GDCM_LIBRARIES}
145             vtkgdcm  
146             )
147         ENDIF(USE_VTK)
148       ENDIF(USE_GDCM_VTK)
149       
150     ENDIF(GDCM_FOUND)
151   ENDIF(NOT GDCM_FOUND)
152 ENDIF(USE_GDCM)
153
154 #-----------------------------------------------------------------------------
155
156 #-----------------------------------------------------------------------------
157 IF(USE_GDCM2)
158   IF(NOT GDCM_FOUND)
159     # Search GDCM2
160     FIND_PACKAGE(GDCM)
161     # If gdcm found
162     IF(GDCM_FOUND)
163       INCLUDE(${GDCM_USE_FILE})
164       
165       IF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
166         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")
167       ENDIF(NOT ${GDCM_MAJOR_VERSION} EQUAL 2)
168       
169       CREA_DEFINE( USE_GDCM2 )
170       CREA_DEFINE_WITH_VAL( GDCM_NAME_SPACE gdcm )
171       
172       MESSAGE ( STATUS "=======================================")
173       MESSAGE ( STATUS "Looking for GDCM2... found")
174       MESSAGE ( STATUS "* Dir       = ${GDCM_DIR}")
175       MESSAGE ( STATUS "* Version   = ${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
176       MESSAGE ( STATUS "* Namespace = ${GDCM_NAME_SPACE}")
177       
178       # Test that GDCM_NAME_SPACE is **NOT** "gdcm" or will conflict with 
179       # embedded gdcm in ITK and will result in hard seg faults !
180       IF(USE_ITK)
181         IF (GDCM_NAME_SPACE STREQUAL "gdcm")
182           MESSAGE(FATAL_ERROR "GDCM_NAME_SPACE value is 'gdcm' which conflicts with ITK embededd gdcm namespace : rebuild gdcm with another GDCM_NAME_SPACE value")
183         ENDIF (GDCM_NAME_SPACE STREQUAL "gdcm")
184       ENDIF(USE_ITK)
185       
186       MARK_AS_ADVANCED(GDCM_DIR)
187       
188       SET(GDCM_LIBRARIES
189         ${GDCM_LIBRARIES} 
190         )
191       
192       # TODO : Test that GDCM was built with option "vtkgdcm"
193       IF(USE_GDCM_VTK)
194         IF(USE_VTK)
195           SET(GDCM_LIBRARIES
196             ${GDCM_LIBRARIES}
197             vtkgdcm  
198             )
199         ENDIF(USE_VTK)
200       ENDIF(USE_GDCM_VTK)
201       
202     ENDIF(GDCM_FOUND)
203   ENDIF(NOT GDCM_FOUND)
204 ENDIF(USE_GDCM2)
205
206 #-----------------------------------------------------------------------------
207
208 #-----------------------------------------------------------------------------
209 IF(USE_WXWIDGETS)
210   IF(NOT wxWidgets_FOUND)
211     INCLUDE(${CREA_CMAKE_DIR}/CREAMacro_FindAndUseWxWidgets.cmake)
212     CREA_FIND_WXWIDGETS()
213     CREA_USE_WXWIDGETS()
214   ENDIF(NOT wxWidgets_FOUND)
215 ENDIF(USE_WXWIDGETS)
216 #-----------------------------------------------------------------------------
217
218
219
220 #-----------------------------------------------------------------------------
221 IF(USE_DOXYGEN) 
222   IF(NOT DOXYGEN)
223     MESSAGE ( STATUS "=======================================")
224     FIND_PACKAGE(Doxygen REQUIRED)
225     #  MESSAGE(STATUS "Looking for doxygen... - found ${DOXYGEN}")
226     #  IF(DOXYGEN)
227     #    
228     #  ELSE(DOXYGEN)
229     #    MESSAGE(FATAL_ERROR "Doxygen not found. Required to build the doxygen documentation")
230   ENDIF(NOT DOXYGEN)
231 ENDIF(USE_DOXYGEN)
232 #-----------------------------------------------------------------------------
233
234
235 #-----------------------------------------------------------------------------
236 IF(USE_LATEX)
237   IF (NOT LATEX_COMPILER)
238     FIND_PACKAGE(LATEX REQUIRED)
239     MESSAGE ( STATUS "=======================================")
240     MESSAGE(STATUS "Looking for latex... - found ${LATEX_COMPILER}")
241   ENDIF (NOT LATEX_COMPILER)
242 ENDIF(USE_LATEX) 
243 #-----------------------------------------------------------------------------
244
245 #-----------------------------------------------------------------------------
246 IF(USE_TTH) 
247   IF (NOT TTH_EXECUTABLE)
248     FIND_FILE( TTH_EXECUTABLE NAME tth tth.exe PATHS . $ENV{CREATIS}/tth_exe/ ~/Creatis/tth ~/Creatis/tth_linux)
249     IF (NOT TTH_EXECUTABLE)
250       MESSAGE(FATAL_ERROR "TTH not found (LATEX_tth_CONVERTER). Required to build the HTML documentation from tex source")
251     ELSE (NOT  TTH_EXECUTABLE)
252       MESSAGE ( STATUS "=======================================")
253       MESSAGE ( STATUS "Looking for tth... - found ${TTH_EXECUTABLE}")
254     ENDIF(NOT TTH_EXECUTABLE)
255     MARK_AS_ADVANCED( TTH_EXECUTABLE )
256   ENDIF(NOT TTH_EXECUTABLE)
257 ENDIF(USE_TTH)
258 #-----------------------------------------------------------------------------
259
260 #-----------------------------------------------------------------------------
261 IF(USE_BOOST)
262   IF(NOT Boost_FOUND)
263     FIND_PACKAGE(Boost REQUIRED)
264     IF(Boost_FOUND)
265       MESSAGE ( STATUS "=======================================")
266       MESSAGE ( STATUS "Looking for boost C++ library... - found in ${Boost_INCLUDE_DIR}")
267       INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})         
268       LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS} )
269           
270            
271       CREA_DEFINE( USE_BOOST )
272           IF(WIN32)
273                 LINK_DIRECTORIES( ${Boost_INCLUDE_DIRS}/lib)
274                 #MESSAGE ("EED " ${Boost_LIBRARY_DIRS})
275                 SET(BOOST_LIBRARIES
276                         libboost_signals-vc71-mt-1_37
277                         libboost_filesystem-vc71-mt-1_37
278             boost_date_time-vc71-mt-1_37
279             )
280           ENDIF(WIN32)
281       IF(NOT WIN32)
282         IF(NOT APPLE)
283           SET(BOOST_LIBRARIES
284             boost_signals
285             boost_filesystem
286             boost_date_time
287             boost_program_options
288             boost_regex
289             )
290         ELSE(NOT APPLE)
291           SET(BOOST_LIBRARIES
292             boost_signals-mt
293             boost_filesystem-mt
294             boost_date_time-mt
295             boost_system-mt
296             boost_program_options-mt
297             boost_regex-mt
298             )
299         ENDIF(NOT APPLE)        
300       ENDIF(NOT WIN32)
301           
302       MARK_AS_ADVANCED(Boost_INCLUDE_DIR)
303     ELSE(Boost_FOUND)
304       MESSAGE(FATAL_ERROR "boost C++ library not found - Set Boost_INCLUDE_DIR to the directory containing boost headers")
305     ENDIF(Boost_FOUND)
306   ENDIF(NOT Boost_FOUND)
307 ENDIF(USE_BOOST)
308 #-----------------------------------------------------------------------------
309
310
311 ENDMACRO(CREA_FIND_AND_USE_LIBRARIES)