]> Creatis software - gdcm.git/blob - CMake/CMakeLists.txt
Avoid polluting command line applications output when no Ethernet cable !
[gdcm.git] / CMake / CMakeLists.txt
1 # Generate the GDCMConfig.cmake file in the build tree. Also configure
2 # one for installation. The file tells external projects how to use
3 # GDCM.
4
5 # Help store a literal dollar in a string.  CMake 2.2 allows escaped
6 # dollars but we have to support CMake 2.0.
7 SET(DOLLAR "$")
8
9 #-----------------------------------------------------------------------------
10 # Settings shared between the build tree and install tree.
11
12 EXPORT_LIBRARY_DEPENDENCIES(
13   ${GDCM_BINARY_DIR}/GDCMLibraryDepends.cmake)
14 INCLUDE(${CMAKE_ROOT}/Modules/CMakeExportBuildSettings.cmake)
15 CMAKE_EXPORT_BUILD_SETTINGS(
16   ${GDCM_BINARY_DIR}/GDCMBuildSettings.cmake)
17
18 IF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
19   INSTALL_FILES(${GDCM_INSTALL_PACKAGE_DIR} FILES
20     ${CMAKE_CURRENT_SOURCE_DIR}/UseGDCM.cmake
21     ${GDCM_BINARY_DIR}/GDCMLibraryDepends.cmake
22     ${GDCM_BINARY_DIR}/GDCMBuildSettings.cmake
23     )
24 ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
25
26 #-----------------------------------------------------------------------------
27 # Settings specific to the build tree.
28
29 # The install-only section is empty for the build tree.
30 SET(GDCM_CONFIG_INSTALL_ONLY)
31
32 # The "use" file.
33 SET(GDCM_USE_FILE_CONFIG 
34   ${CMAKE_CURRENT_SOURCE_DIR}/UseGDCM.cmake)
35
36 # The build settings file.
37 SET(GDCM_BUILD_SETTINGS_FILE_CONFIG 
38   ${GDCM_BINARY_DIR}/GDCMBuildSettings.cmake)
39
40 # The library directories.
41 SET(GDCM_LIBRARY_DIRS_CONFIG ${GDCM_LIBRARY_DIRS})
42
43 # The runtime directories.
44 SET(GDCM_RUNTIME_DIRS_CONFIG ${GDCM_RUNTIME_DIRS})
45
46 # The include directories.
47 SET(GDCM_INCLUDE_DIRS_CONFIG ${GDCM_INCLUDE_PATH})
48
49 # The library dependencies file.
50 SET(GDCM_LIBRARY_DEPENDS_FILE 
51   ${GDCM_BINARY_DIR}/GDCMLibraryDepends.cmake)
52
53 # The data dir.
54 SET(GDCM_DATA_DIR_CONFIG
55   ${GDCM_DATA_DIR})
56
57 # The examples dir.
58 SET(GDCM_EXAMPLES_DIR_CONFIG 
59   ${GDCM_EXAMPLES_DIR})
60
61 # The templates dir.
62 #SET(GDCM_TEMPLATES_DIR_CONFIG 
63 #  ${GDCM_TEMPLATES_DIR})
64
65 # The resources dir.
66 #SET(GDCM_RESOURCES_DIR_CONFIG 
67 #  ${GDCM_RESOURCES_DIR})
68
69 # The CMake macros dir.
70 SET(GDCM_CMAKE_DIR_CONFIG 
71   ${GDCM_CMAKE_DIR})
72
73 # The Tcl/Tk options.
74 #SET(GDCM_TCL_PACKAGE_INDEX_DIR_CONFIG ${GDCM_TCL_PACKAGE_INDEX_DIR})
75
76 # The Python options.
77 SET(GDCM_PYTHON_MODULE_DIR_CONFIG ${GDCM_PYTHON_MODULE_DIR})
78
79 # The Doxygen options.
80 SET(GDCM_DOXYGEN_DIR_CONFIG ${GDCM_SOURCE_DIR}/Utilities/Doxygen)
81
82 # The VTK options.
83 SET(GDCM_VTK_DIR_CONFIG ${VTK_DIR})
84
85 # The build configuration information.
86 SET(GDCM_CONFIGURATION_TYPES_CONFIG ${GDCM_CONFIGURATION_TYPES})
87 SET(GDCM_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
88
89 # Configure GDCMConfig.cmake for the build tree.
90 CONFIGURE_FILE(
91   ${CMAKE_CURRENT_SOURCE_DIR}/GDCMConfig.cmake.in
92   ${GDCM_BINARY_DIR}/GDCMConfig.cmake @ONLY IMMEDIATE)
93
94 #-----------------------------------------------------------------------------
95 # Settings specific to the install tree.
96
97 # The "use" file.
98 SET(GDCM_USE_FILE_CONFIG 
99   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_PACKAGE_DIR}/UseGDCM.cmake)
100
101 # The build settings file.
102 SET(GDCM_BUILD_SETTINGS_FILE_CONFIG 
103   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_PACKAGE_DIR}/GDCMBuildSettings.cmake)
104
105 # The library directories.
106 IF(CYGWIN AND GDCM_BUILD_SHARED_LIBS)
107   # In Cygwin programs directly link to the .dll files.
108   SET(GDCM_LIBRARY_DIRS_CONFIG 
109     ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_BIN_DIR})
110 ELSE(CYGWIN AND GDCM_BUILD_SHARED_LIBS)
111   SET(GDCM_LIBRARY_DIRS_CONFIG 
112     ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_LIB_DIR})
113 ENDIF(CYGWIN AND GDCM_BUILD_SHARED_LIBS)
114
115 # The runtime directories.
116 IF(WIN32)
117   SET(GDCM_RUNTIME_DIRS_CONFIG 
118     ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_BIN_DIR})
119 ELSE(WIN32)
120   SET(GDCM_RUNTIME_DIRS_CONFIG 
121     ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_LIB_DIR})
122 ENDIF(WIN32)
123
124 # The include directories.
125 SET(GDCM_INCLUDE_DIRS_CONFIG
126   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_INCLUDE_DIR})
127
128 # The library dependencies file.
129 SET(GDCM_LIBRARY_DEPENDS_FILE 
130   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_PACKAGE_DIR}/GDCMLibraryDepends.cmake)
131
132 # The data dir.
133 SET(GDCM_DATA_DIR
134   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_DATA_DIR}/Data)
135
136 # The examples dir.
137 SET(GDCM_EXAMPLES_DIR_CONFIG 
138   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_DATA_DIR}/Examples)
139
140 # The templates dir.
141 #SET(GDCM_TEMPLATES_DIR_CONFIG 
142 # ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_INCLUDE_DIR}/Templates)
143
144 # The resources dir.
145 #SET(GDCM_RESOURCES_DIR_CONFIG 
146 #  ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_DATA_DIR}/Resources)
147
148 # The CMake macros dir.
149 SET(GDCM_CMAKE_DIR_CONFIG 
150   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_PACKAGE_DIR}/CMake)
151
152 # The Tcl/Tk options.
153 #SET(GDCM_TCL_PACKAGE_INDEX_DIR_CONFIG 
154 #  ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_LIB_DIR}/tcl)
155
156 # The Python options.
157 #IF(WIN32)
158 #  SET(python_subdir "")
159 #ELSE(WIN32)
160 #  IF(PYTHON_EXECUTABLE)
161 #    EXEC_PROGRAM("${PYTHON_EXECUTABLE}" ARGS "-V" OUTPUT_VARIABLE version)
162 #    STRING(REGEX REPLACE "^(Python )([0-9]\\.[0-9])(.*)$" "\\2" 
163 #      major_minor "${version}")
164 #    SET(python_subdir "python${major_minor}/")
165 #  ELSE(PYTHON_EXECUTABLE)
166 #    SET(python_subdir "python2.4/")
167 #  ENDIF(PYTHON_EXECUTABLE)
168 #ENDIF(WIN32)
169 #SET(GDCM_PYTHON_MODULE_DIR_CONFIG 
170 #  ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_LIB_DIR}/../${python_subdir}site-packages)
171
172 # The Doxygen options.
173 SET(GDCM_DOXYGEN_DIR_CONFIG 
174   ${DOLLAR}{GDCM_INSTALL_PREFIX}${GDCM_INSTALL_DOXYGEN_DIR})
175
176 # The VTK options.
177 # If VTK_BINARY_DIR is set, then GDCM is part of a larger parent project
178 # that also builds VTK. In that case, GDCM_VTK_INSTALL_PACKAGE_DIR
179 # should be set to the value of VTK_INSTALL_PACKAGE_DIR. Otherwise, if not set,
180 # then we are using an outside VTK whose location will not change when we
181 # install.
182 IF(VTK_BINARY_DIR)
183   IF(NOT GDCM_VTK_INSTALL_PACKAGE_DIR)
184     MESSAGE(
185       FATAL_ERROR 
186       "GDCM_VTK_INSTALL_PACKAGE_DIR must be set by the parent project to the value of VTK_INSTALL_PACKAGE_DIR it uses to configure VTK.")
187   ENDIF(NOT GDCM_VTK_INSTALL_PACKAGE_DIR)
188   SET(GDCM_VTK_DIR_CONFIG ${GDCM_VTK_INSTALL_PACKAGE_DIR})
189 ELSE(VTK_BINARY_DIR)
190   SET(GDCM_VTK_DIR_CONFIG ${VTK_DIR})
191 ENDIF(VTK_BINARY_DIR)
192
193 # The build configuration information.
194 # The install tree only has one configuration.
195 SET(GDCM_CONFIGURATION_TYPES_CONFIG)
196
197 # Configure GDCMConfig.cmake for the install tree.
198
199 # Construct the proper number of GET_FILENAME_COMPONENT(... PATH)
200 # calls to compute the installation prefix from GDCM_DIR.
201 STRING(REGEX REPLACE "/" ";" GDCM_INSTALL_PACKAGE_DIR_COUNT
202   "${GDCM_INSTALL_PACKAGE_DIR}")
203 SET(GDCM_CONFIG_INSTALL_ONLY "
204 # Compute the installation prefix from GDCM_DIR.
205 SET(GDCM_INSTALL_PREFIX \"${DOLLAR}{GDCM_DIR}\")
206 ")
207 FOREACH(p ${GDCM_INSTALL_PACKAGE_DIR_COUNT})
208   SET(GDCM_CONFIG_INSTALL_ONLY
209     "${GDCM_CONFIG_INSTALL_ONLY}GET_FILENAME_COMPONENT(GDCM_INSTALL_PREFIX \"${DOLLAR}{GDCM_INSTALL_PREFIX}\" PATH)\n"
210     )
211 ENDFOREACH(p)
212
213 IF(CMAKE_CONFIGURATION_TYPES)
214   # There are multiple build configurations.  Configure one
215   # GDCMConfig.cmake for each configuration.
216   FOREACH(config ${CMAKE_CONFIGURATION_TYPES})
217     SET(GDCM_BUILD_TYPE_CONFIG ${config})
218     CONFIGURE_FILE(
219       ${CMAKE_CURRENT_SOURCE_DIR}/GDCMConfig.cmake.in
220       ${CMAKE_CURRENT_BINARY_DIR}/${config}/GDCMConfig.cmake
221       @ONLY IMMEDIATE)
222   ENDFOREACH(config)
223
224   # Install the config file corresponding to the build configuration
225   # specified when building the install target.  The BUILD_TYPE variable
226   # will be set while CMake is processing the install files.
227   IF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
228     INSTALL_FILES(${GDCM_INSTALL_PACKAGE_DIR} FILES
229       ${CMAKE_CURRENT_BINARY_DIR}/${DOLLAR}{BUILD_TYPE}/GDCMConfig.cmake)
230   ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
231 ELSE(CMAKE_CONFIGURATION_TYPES)
232   # There is only one build configuration. Configure one GDCMConfig.cmake.
233   SET(GDCM_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
234   CONFIGURE_FILE(
235     ${CMAKE_CURRENT_SOURCE_DIR}/GDCMConfig.cmake.in
236     ${CMAKE_CURRENT_BINARY_DIR}/GDCMConfig.cmake @ONLY IMMEDIATE)
237
238   # Setup an install rule for the config file.
239   IF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
240     INSTALL_FILES(${GDCM_INSTALL_PACKAGE_DIR} FILES
241       ${CMAKE_CURRENT_BINARY_DIR}/GDCMConfig.cmake)
242   ENDIF(NOT GDCM_INSTALL_NO_DEVELOPMENT)
243 ENDIF(CMAKE_CONFIGURATION_TYPES)
244
245