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