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