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