2 CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
3 # okay in fact you need at least cmake 2.0.4 to get swig working properly
4 # and you cannot use cmake 2.0.6 out of the box due to a bug (patched in debian package)
6 #-----------------------------------------------------------------------------
7 # GDCM version number, usefull for packaging and doxygen doc:
8 SET(GDCM_MAJOR_VERSION 1)
9 SET(GDCM_MINOR_VERSION 3)
10 SET(GDCM_BUILD_VERSION 2)
12 "${GDCM_MAJOR_VERSION}.${GDCM_MINOR_VERSION}.${GDCM_BUILD_VERSION}")
14 #-----------------------------------------------------------------------------
15 # Provide compatibility options.
16 OPTION(GDCM_LEGACY_REMOVE "Remove all legacy code completely." OFF)
17 OPTION(GDCM_LEGACY_SILENT "Silence all legacy code messages." OFF)
18 MARK_AS_ADVANCED(GDCM_LEGACY_REMOVE GDCM_LEGACY_SILENT)
20 # VS 2005 declared that some C functions were deprecated...
21 IF(CMAKE_COMPILER_2005)
22 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
23 ADD_DEFINITIONS(-D_SCL_SECURE_NO_DEPRECATE)
24 ENDIF(CMAKE_COMPILER_2005)
26 #-----------------------------------------------------------------------------
27 # Build shared lib by default
28 OPTION(BUILD_SHARED_LIBS "Build GDCM with shared libraries." ON)
30 SET(GDCM_CMAKE_DIR "${GDCM_SOURCE_DIR}/Utilities/CMake")
31 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GDCM_CMAKE_DIR}")
33 SET(GDCM_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES})
35 OPTION(GDCM_DEBUG "Turn verbosity of some statement ON." OFF)
36 MARK_AS_ADVANCED(GDCM_DEBUG)
38 # --------------------------------------------------------------------------
39 SET (GDCM_NAME_SPACE gdcm CACHE STRING "name space")
41 # --------------------------------------------------------------------------
43 STRING(TOLOWER ${PROJECT_NAME} project_name)
45 IF(NOT GDCM_INSTALL_BIN_DIR)
46 SET(GDCM_INSTALL_BIN_DIR "/bin")
47 ENDIF(NOT GDCM_INSTALL_BIN_DIR)
49 IF(NOT GDCM_INSTALL_LIB_DIR)
50 SET(GDCM_INSTALL_LIB_DIR "/lib/${project_name}")
51 ENDIF(NOT GDCM_INSTALL_LIB_DIR)
53 IF(NOT GDCM_INSTALL_DATA_DIR)
54 SET(GDCM_INSTALL_DATA_DIR "/share/${project_name}")
55 ENDIF(NOT GDCM_INSTALL_DATA_DIR)
57 IF(NOT GDCM_INSTALL_INCLUDE_DIR)
58 SET(GDCM_INSTALL_INCLUDE_DIR "/include/${project_name}")
59 ENDIF(NOT GDCM_INSTALL_INCLUDE_DIR)
61 IF(NOT GDCM_INSTALL_PACKAGE_DIR)
62 SET(GDCM_INSTALL_PACKAGE_DIR ${GDCM_INSTALL_LIB_DIR})
63 ENDIF(NOT GDCM_INSTALL_PACKAGE_DIR)
65 IF(NOT GDCM_VTK_INSTALL_PACKAGE_DIR)
66 SET(GDCM_VTK_INSTALL_PACKAGE_DIR ${VTK_INSTALL_PACKAGE_DIR})
67 ENDIF(NOT GDCM_VTK_INSTALL_PACKAGE_DIR)
69 IF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
70 SET(GDCM_INSTALL_NO_DEVELOPMENT 0)
71 ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
73 IF(NOT GDCM_INSTALL_NO_RUNTIME)
74 SET(GDCM_INSTALL_NO_RUNTIME 0)
75 ENDIF(NOT GDCM_INSTALL_NO_RUNTIME)
77 IF(NOT GDCM_INSTALL_NO_DOCUMENTATION)
78 SET(GDCM_INSTALL_NO_DOCUMENTATION 0)
79 ENDIF(NOT GDCM_INSTALL_NO_DOCUMENTATION)
81 SET(GDCM_INSTALL_NO_LIBRARIES)
82 IF(GDCM_BUILD_SHARED_LIBS)
83 IF(GDCM_INSTALL_NO_RUNTIME AND GDCM_INSTALL_NO_DEVELOPMENT)
84 SET(GDCM_INSTALL_NO_LIBRARIES 1)
85 ENDIF(GDCM_INSTALL_NO_RUNTIME AND GDCM_INSTALL_NO_DEVELOPMENT)
86 ELSE(GDCM_BUILD_SHARED_LIBS)
87 IF(GDCM_INSTALL_NO_DEVELOPMENT)
88 SET(GDCM_INSTALL_NO_LIBRARIES 1)
89 ENDIF(GDCM_INSTALL_NO_DEVELOPMENT)
90 ENDIF(GDCM_BUILD_SHARED_LIBS)
92 #-----------------------------------------------------------------------------
93 SET (EXECUTABLE_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
94 SET (LIBRARY_OUTPUT_PATH ${GDCM_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
95 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
98 #-----------------------------------------------------------------------------
99 # Test if compiler defines the pseudo-macro __FUNCTION__
100 IF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$")
101 MESSAGE(STATUS "Checking support for __FUNCTION__ in compiler")
102 TRY_COMPILE(GDCM_COMPILER_HAS_FUNCTION
103 ${GDCM_BINARY_DIR}/CMakeTmp/Function
104 ${GDCM_SOURCE_DIR}/CMake/gdcmTestFUNCTION.cxx
105 OUTPUT_VARIABLE OUTPUT)
106 IF(GDCM_COMPILER_HAS_FUNCTION)
107 MESSAGE(STATUS "Checking support for __FUNCTION__ -- yes")
108 SET(GDCM_COMPILER_HAS_FUNCTION 1 CACHE INTERNAL "Support for extension C __FUNCTION__")
109 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
110 "Determining if the C compiler supports __FUNCTION__ "
111 "passed with the following output:\n"
112 "${OUTPUT}\n" APPEND)
113 ELSE(GDCM_COMPILER_HAS_FUNCTION)
114 MESSAGE(STATUS "Checking support for __FUNCTION__ -- no")
115 SET(GDCM_COMPILER_HAS_FUNCTION 0 CACHE INTERNAL "Support for extension C __FUNCTION__")
116 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
117 "Determining if the C compiler supports __FUNCTION__ "
118 "failed with the following output:\n"
119 "${OUTPUT}\n" APPEND)
120 ENDIF(GDCM_COMPILER_HAS_FUNCTION)
121 ENDIF("GDCM_COMPILER_HAS_FUNCTION" MATCHES "^GDCM_COMPILER_HAS_FUNCTION$")
123 #-----------------------------------------------------------------------------
124 # Test is compiler support istringstream
125 IF("GDCM_TEST_ISTRINGSTREAM" MATCHES "^GDCM_TEST_ISTRINGSTREAM$")
126 MESSAGE(STATUS "Checking istringstream")
127 TRY_RUN(GDCM_TEST_ISTRINGSTREAM GDCM_TEST_ISTRINGSTREAM_COMPILED
128 ${GDCM_BINARY_DIR}/CMakeTmp/
129 ${GDCM_SOURCE_DIR}/CMake/gdcmTestIstringStream.cxx)
130 IF(GDCM_TEST_ISTRINGSTREAM_COMPILED)
131 IF(GDCM_TEST_ISTRINGSTREAM)
132 MESSAGE(STATUS "Checking istringstream works -- yes")
133 SET(GDCM_TEST_ISTRINGSTREAM 1 CACHE INTERNAL "Whether istringstream works.")
134 ELSE(GDCM_TEST_ISTRINGSTREAM)
135 MESSAGE(STATUS "Checking istringstream works -- no")
136 SET(GDCM_TEST_ISTRINGSTREAM 0 CACHE INTERNAL "Whether istringstream works.")
137 ENDIF(GDCM_TEST_ISTRINGSTREAM)
138 ELSE(GDCM_TEST_ISTRINGSTREAM_COMPILED)
139 MESSAGE(STATUS "Checking istringstream -- failed")
140 ENDIF(GDCM_TEST_ISTRINGSTREAM_COMPILED)
141 ENDIF("GDCM_TEST_ISTRINGSTREAM" MATCHES "^GDCM_TEST_ISTRINGSTREAM$")
143 #-----------------------------------------------------------------------------
144 # Build directory on which many applications depend
149 #-----------------------------------------------------------------------------
152 OPTION(BUILD_EXAMPLES "Build GDCM examples." ON)
155 ENDIF(BUILD_EXAMPLES)
157 #-----------------------------------------------------------------------------
158 # Adding GDCM_DATA_ROOT
159 FIND_PATH(GDCM_DATA_ROOT gdcm-ACR-LibIDO.acr
160 ${GDCM_SOURCE_DIR}/../gdcmData
162 $ENV{PUB_DICT_PATH}/../../gdcmData
164 # Adding GDCM_DATA_ROOT
165 FIND_PATH(GDCM_DATA_EXTRA_ROOT gdcmData.tar.gz
166 ${GDCM_SOURCE_DIR}/../gdcmDataExtra
169 # Set the place for the public dictionary, must be set before gdcmConfigure.h
170 FIND_PATH(GDCM_PUB_DICT_PATH dicomV3.dic
171 ${GDCM_SOURCE_DIR}/Dicts
175 #-----------------------------------------------------------------------------
176 # SunOS + old gcc fixes:
177 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
178 IF(CMAKE_NO_ANSI_STRING_STREAM)
179 SET(GDCM_NO_ANSI_STRING_STREAM 1)
180 ENDIF(CMAKE_NO_ANSI_STRING_STREAM)
183 INCLUDE (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
184 TEST_BIG_ENDIAN(GDCM_WORDS_BIGENDIAN)
186 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
187 CHECK_INCLUDE_FILE("stdint.h" CMAKE_HAVE_STDINT_H)
188 IF(UNIX) #Avoid polluting Win32 cmakecache
189 CHECK_INCLUDE_FILE("inttypes.h" CMAKE_HAVE_INTTYPES_H)
191 # Special Time support, two convention: *NIX vs Win32
192 CHECK_INCLUDE_FILE("sys/times.h" CMAKE_HAVE_SYS_TIMES_H)
193 CHECK_INCLUDE_FILE("sys/timeb.h" CMAKE_HAVE_SYS_TIMEB_H)
195 # Check if header file exists and add it to the list.
196 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
197 MACRO(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
198 CHECK_INCLUDE_FILES("${GDCM_INCLUDES};${FILE}" ${VARIABLE})
200 SET(GDCM_INCLUDES ${GDCM_INCLUDES} ${FILE})
202 ENDMACRO(CHECK_INCLUDE_FILE_CONCAT)
204 # Need those header for GetMacAddress in Util
205 # This is tricky as you need to figure out the proper order to
206 # test the inclusion of files
207 CHECK_INCLUDE_FILE_CONCAT("unistd.h" CMAKE_HAVE_UNISTD_H)
208 CHECK_INCLUDE_FILE_CONCAT("stdlib.h" CMAKE_HAVE_STDLIB_H)
209 IF(UNIX) #Avoid polluting Win32 cmakecache
210 CHECK_INCLUDE_FILE_CONCAT("sys/ioctl.h" CMAKE_HAVE_SYS_IOCTL_H)
211 CHECK_INCLUDE_FILE_CONCAT("sys/socket.h" CMAKE_HAVE_SYS_SOCKET_H)
212 CHECK_INCLUDE_FILE_CONCAT("sys/sockio.h" CMAKE_HAVE_SYS_SOCKIO_H)
213 CHECK_INCLUDE_FILE_CONCAT("net/if.h" CMAKE_HAVE_NET_IF_H)
214 CHECK_INCLUDE_FILE_CONCAT("netinet/in.h" CMAKE_HAVE_NETINET_IN_H)
215 CHECK_INCLUDE_FILE_CONCAT("net/if_dl.h" CMAKE_HAVE_NET_IF_DL_H)
216 CHECK_INCLUDE_FILE_CONCAT("net/if_arp.h" CMAKE_HAVE_NET_IF_ARP_H)
219 #-----------------------------------------------------------------------------
220 # Test if os defines a length for sockaddr
221 # only doing the test when we have sys/socket
222 IF( ${CMAKE_HAVE_SYS_SOCKET_H} )
223 IF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$")
224 STRING(ASCII 35 POUND)
225 FILE(WRITE ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
226 "${POUND}include <sys/types.h>\n"
227 "${POUND}include <sys/socket.h>\n"
228 "int main() { struct sockaddr sa; sa.sa_len = 0; }\n")
229 MESSAGE(STATUS "Checking if ifreq has a sa_len")
230 TRY_COMPILE(HAVE_SA_LEN
232 ${GDCM_BINARY_DIR}/CMakeTmp/gdcmTestHAVESALEN.c
233 OUTPUT_VARIABLE OUTPUT)
235 MESSAGE(STATUS "Checking if ifreq has a sa_len -- yes")
236 SET(HAVE_SA_LEN 1 CACHE INTERNAL "Support if ifreq has a sa_len")
237 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
238 "Determining if ifreq has a sa_len"
239 "passed with the following output:\n"
240 "${OUTPUT}\n" APPEND)
242 MESSAGE(STATUS "Checking if ifreq has a sa_len -- no")
243 SET(HAVE_SA_LEN 0 CACHE INTERNAL "Support if ifreq has a sa_len")
244 WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
245 "Determining if ifreq has a sa_len"
246 "failed with the following output:\n"
247 "${OUTPUT}\n" APPEND)
249 ENDIF("HAVE_SA_LEN" MATCHES "^HAVE_SA_LEN$")
250 ENDIF( ${CMAKE_HAVE_SYS_SOCKET_H} )
252 #-----------------------------------------------------------------------------
253 # Force Big Endian emulation on little endian:
254 OPTION(GDCM_FORCE_BIGENDIAN_EMULATION "Force Big Endian Emulation. Don't use if you don't know what you are doing." OFF)
256 CONFIGURE_FILE(${GDCM_SOURCE_DIR}/gdcmConfigure.h.in
257 ${GDCM_BINARY_DIR}/gdcmConfigure.h @ONLY IMMEDIATE
260 IF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
261 INSTALL_FILES(${GDCM_INSTALL_INCLUDE_DIR} FILES gdcmConfigure.h)
262 ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
264 #-----------------------------------------------------------------------------
265 # Add the testing directories
266 OPTION(BUILD_TESTING "Build testing." ON)
269 CONFIGURE_FILE(${GDCM_SOURCE_DIR}/CMake/CTestCustom.ctest.in
270 ${GDCM_BINARY_DIR}/CMake/CTestCustom.ctest @ONLY)
271 FILE(WRITE ${GDCM_BINARY_DIR}/CTestCustom.cmake
272 "INCLUDE(\"${GDCM_BINARY_DIR}/CMake/CTestCustom.ctest\")\n")
279 #-----------------------------------------------------------------------------
280 OPTION(GDCM_VTK "Build VTK-GDCM Lib." OFF)
286 #INCLUDE(${VTK_USE_FILE})
291 #-----------------------------------------------------------------------------
292 OPTION(GDCM_WRAP_PYTHON "Wrap GDCM classes into the Python language." OFF)
295 # Search Python libs:
296 FIND_PACKAGE(PythonLibs)
297 # If PythonLibs found
300 ENDIF(PYTHON_LIBRARY)
301 ENDIF(GDCM_WRAP_PYTHON)
303 #-----------------------------------------------------------------------------
304 OPTION(GDCM_DOCUMENTATION "Build source documentation using doxygen." OFF)
306 IF(GDCM_DOCUMENTATION)
308 FIND_PACKAGE(Doxygen)
312 ENDIF(GDCM_DOCUMENTATION)
314 #-----------------------------------------------------------------------------
316 OPTION(GDCM_INSTALLER "Build the install setup using InnoSetup." OFF)
319 OPTION(GDCM_INSTALLER "Prepare the rpmBuild use." OFF)
323 ENDIF(GDCM_INSTALLER)
325 # --------------------------------------------------------------------------
326 # Configure the export configuration