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