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