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