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