MIRTKConfig.cmake
1 # ==============================================================================
2 # Medical Image Registration ToolKit (MIRTK)
3 #
4 # Copyright 2013-2016 Imperial College London
5 # Copyright 2013-2016 Andreas Schuh
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ==============================================================================
19 
20 ##############################################################################
21 # @file MIRTKConfig.cmake
22 # @brief CMake package configuration file.
23 #
24 # @note The MIRTKConfig.cmake file is automatically generated
25 # by BASIS from the template file Config.cmake.in which is part of
26 # the BASIS package.
27 #
28 # Variables in this file have to be prefixed by the name of this package.
29 # In the default package configuration file of BASIS, which can be included
30 # here using the \@BASIS_CONFIG\@ variable, this prefix is defined as @c NS
31 # variable. Moreover, the macro basis_set_config() should be used for
32 # convenience to set any configuration variable, e.g.,
33 #
34 # @code
35 # basis_set_config (INCLUDE_DIR "\@INCLUDE_DIR_CONFIG\@")
36 # @endcode
37 #
38 # where the variable @c INCLUDE_DIR_CONFIG is set in the ConfigSettings.cmake
39 # file of the BASIS installation. Note that this statement will set the
40 # variable ${NS}INCLUDE_DIR, where by default @c NS is the package name
41 # followed by an underscore (_).
42 #
43 # See the Config.cmake.in file of BASIS for details.
44 #
45 # @ingroup BasisConfig
46 ##############################################################################
47 
48 ## @addtogroup BasisConfig
49 # @{
50 
51 # ============================================================================
52 # List of requested modules
53 # ============================================================================
54 
55 if (MIRTK_FIND_COMPONENTS)
56  set(MIRTK_MODULES_REQUESTED "${MIRTK_FIND_COMPONENTS}")
57  foreach (_CMP IN ITEMS BASIS CMake)
58  list(FIND MIRTK_MODULES_REQUESTED ${_CMP} _IDX)
59  if (_IDX EQUAL -1)
60  set(_INCLUDE_${_CMP}_MODULES FALSE)
61  else ()
62  list(REMOVE_ITEM MIRTK_MODULES_REQUESTED ${_CMP})
63  set(_INCLUDE_${_CMP}_MODULES TRUE)
64  endif ()
65  endforeach ()
66  unset(_CMP)
67  unset(_IDX)
68 endif ()
69 
70 
71 # ============================================================================
72 # namespace
73 # ============================================================================
74 
75 # prefix used for variable names
76 set (NS "MIRTK_")
77 
78 # allow caller to change namespace - used by projects with modules
79 if (${NS}CONFIG_PREFIX)
80  set (NS "${${NS}CONFIG_PREFIX}_")
81 endif ()
82 
83 # ----------------------------------------------------------------------------
84 macro (basis_set_config NAME)
85  set (${NS}${NAME} ${ARGN})
86 endmacro ()
87 
88 # ----------------------------------------------------------------------------
89 macro (basis_copy_config NAME SRC)
90  set (${NS}${NAME} ${${NS}${SRC}})
91 endmacro ()
92 
93 # ----------------------------------------------------------------------------
94 macro (basis_append_config NAME)
95  list (APPEND ${NS}${NAME} ${ARGN})
96 endmacro ()
97 
98 # ----------------------------------------------------------------------------
99 macro (basis_find_config NAME VALUE IDX)
100  list (FIND ${NS}${NAME} "${VALUE}" ${IDX})
101 endmacro ()
102 
103 # ----------------------------------------------------------------------------
104 macro (basis_remove_duplicates_config NAME)
105  if (${NS}${NAME})
106  list (REMOVE_DUPLICATES ${NS}${NAME})
107  endif ()
108 endmacro ()
109 
110 # ----------------------------------------------------------------------------
111 macro (basis_remove_item_config NAME ITEM)
112  if (${NS}${NAME})
113  list (REMOVE_ITEM ${NS}${NAME} "${ITEM}")
114  endif ()
115 endmacro ()
116 
117 # ----------------------------------------------------------------------------
118 if (NOT COMMAND basis_is_cached)
119  macro (basis_is_cached VAR ENTRY)
120  if (DEFINED ${ENTRY})
121  get_property (${VAR} CACHE ${ENTRY} PROPERTY TYPE SET)
122  else ()
123  set (${VAR} FALSE)
124  endif ()
125  endmacro ()
126 endif ()
127 
128 # ----------------------------------------------------------------------------
129 if (NOT COMMAND basis_set_or_update_value)
130  macro (basis_set_or_update_value VAR)
131  basis_is_cached (_CACHED ${VAR})
132  if (_CACHED)
133  if (${ARGC} GREATER 1)
134  set_property (CACHE ${VAR} PROPERTY VALUE ${ARGN})
135  else ()
136  set (${VAR} "" CACHE INTERNAL "" FORCE)
137  endif ()
138  else ()
139  set (${VAR} ${ARGN})
140  endif ()
141  unset (_CACHED)
142  endmacro ()
143 endif ()
144 
145 # ============================================================================
146 # general
147 # ============================================================================
148 
149 ## @brief Installation prefix or root of build tree.
150 basis_set_config (INSTALL_PREFIX "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release")
151 get_filename_component (${NS}INSTALL_PREFIX "${${NS}INSTALL_PREFIX}" ABSOLUTE)
152 
153 ## @brief Project use file to be included by other projects.
154 basis_set_config (USE_FILE "${CMAKE_CURRENT_LIST_DIR}/MIRTKUse.cmake")
155 
156 ## @brief Directory of example files.
157 basis_set_config (EXAMPLE_DIR "")
158 
159 # ============================================================================
160 # libraries
161 # ============================================================================
162 
163 ## @brief Directory of header files.
164 basis_set_config (INCLUDE_DIR "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/include;/Users/as12312/Software/MIRTK/Maintenance/include")
165 
166 ## @brief Directory of header files including dependencies.
167 basis_set_config (INCLUDE_DIRS) # to have a set recognized by Doxygen filter
168 basis_copy_config (INCLUDE_DIRS INCLUDE_DIR)
169 basis_append_config (INCLUDE_DIRS "")
170 
171 ## @brief Directory of libraries.
172 basis_set_config (LIBRARY_DIR "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib")
173 
174 ## @brief Directory of libraries including dependencies.
175 basis_set_config (LIBRARY_DIRS) # to have a set() recognized by Doxygen filter
176 basis_copy_config (LIBRARY_DIRS LIBRARY_DIR)
177 basis_append_config (LIBRARY_DIRS "")
178 
179 ## @brief Search path for Python modules.
180 basis_set_config (PYTHONPATH "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/python")
181 
182 ## @brief Search path for Jython modules.
183 basis_set_config (JYTHONPATH "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/jython")
184 
185 ## @brief Search path for Perl modules.
186 basis_set_config (PERL5LIB "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/perl")
187 
188 ## @brief Search path for MATLAB modules.
189 basis_set_config (MATLABPATH "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/matlab")
190 
191 ## @brief Search path for Bash modules.
192 #
193 # See the import() function of the BASIS Bash utilities.
194 basis_set_config (BASHPATH "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/bash")
195 
196 # ============================================================================
197 # exports
198 # ============================================================================
199 
200 ## @brief Absolute path of exports file to be included by other projects.
201 basis_set_config (EXPORTS_FILE "${CMAKE_CURRENT_LIST_DIR}/MIRTKTargets.cmake")
202 
203 ## @brief Absolute path of custom exports file to be included by other projects.
204 basis_set_config (CUSTOM_EXPORTS_FILE "${CMAKE_CURRENT_LIST_DIR}/MIRTKCustomTargets.cmake")
205 
206 # ============================================================================
207 # modules
208 # ============================================================================
209 
210 ## @brief Directory containing module configuration files
211 basis_set_config (MODULES_DIR "/Users/as12312/Software/MIRTK/Maintenance/Build/Clang_x86_64/Release/lib/cmake/mirtk")
212 
213 ## @brief List of known project modules.
214 basis_set_config (MODULES "Common;IO;Image;Numerics;PointSet;Registration;Transformation;Deformable;Mapping;DrawEM;Scripting;Applications")
215 
216 ## @brief List of found requested modules.
217 basis_set_config (MODULES_FOUND)
218 
219 ## @brief List of not found optional modules.
220 basis_set_config (MODULES_NOTFOUND)
221 
222 ## @brief List of available project modules.
223 basis_set_config (MODULES_ENABLED)
224 file (GLOB _CONFIG_FILES "${${NS}MODULES_DIR}/MIRTK*Config.cmake")
225 foreach (_CONFIG_FILE IN LISTS _CONFIG_FILES)
226  if (_CONFIG_FILE MATCHES "/MIRTK([^ /][^ /]*)Config.cmake")
227  set (_MODULE_NAME ${CMAKE_MATCH_1})
228  basis_append_config (MODULES ${_MODULE_NAME})
229  basis_append_config (MODULES_ENABLED ${_MODULE_NAME})
230  endif ()
231 endforeach ()
232 
233 basis_remove_duplicates_config (MODULES)
234 basis_remove_duplicates_config (MODULES_ENABLED)
235 
236 unset (_CONFIG_FILES)
237 unset (_CONFIG_FILE)
238 
239 ## @brief List of modules requested by external package using the
240 # @c COMPONENTS argument of
241 # <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package">
242 # find_package()</a>.
243 if (NOT DEFINED ${NS}MODULES_REQUESTED)
244  if (${NS}FIND_COMPONENTS)
245  basis_copy_config (MODULES_REQUESTED FIND_COMPONENTS)
246  endif ()
247  if (NOT ${NS}MODULES_REQUESTED)
248  basis_copy_config (MODULES_REQUESTED MODULES_ENABLED)
249  endif ()
250 endif ()
251 basis_remove_duplicates_config (MODULES_REQUESTED)
252 
253 set (_PACKAGE_NS "${NS}")
254 foreach (_MODULE_NAME IN LISTS ${NS}MODULES_REQUESTED)
255  # check if requested module is available
256  basis_find_config (MODULES_ENABLED ${_MODULE_NAME} _MODULE_IDX)
257  if (_MODULE_IDX EQUAL -1)
258  # set <Pkg>_<Module>_FOUND = FALSE
259  basis_set_config (${_MODULE_NAME}_FOUND FALSE)
260  # append to list of not found requested modules
261  basis_append_config (MODULES_NOTFOUND ${_MODULE_NAME})
262  else ()
263  set (_MODULE_NS "${NS}${_MODULE_NAME}_")
264  # include configuration file of module
265  set (${_MODULE_NAME}_CONFIG_PREFIX "${_MODULE_NS}")
266  include ("${${NS}MODULES_DIR}/MIRTK${_MODULE_NAME}Config.cmake")
267  unset (${_MODULE_NAME}_CONFIG_PREFIX)
268  set (NS "${_PACKAGE_NS}") # restore NS of this package config
269  # append include directories
270  if (${_MODULE_NS}INCLUDE_DIRS)
271  basis_append_config (INCLUDE_DIRS ${${_MODULE_NS}INCLUDE_DIRS})
272  elseif (${_MODULE_NS}INCLUDE_DIR)
273  basis_append_config (INCLUDE_DIRS ${${_MODULE_NS}INCLUDE_DIR})
274  endif ()
275  # append library directories
276  if (${_MODULE_NS}LIBRARY_DIRS)
277  basis_append_config (LIBRARY_DIRS ${${_MODULE_NS}LIBRARY_DIRS})
278  elseif (${_MODULE_NS}LIBARY_DIR)
279  basis_append_config (LIBRARY_DIRS ${${_MODULE_NS}LIBRARY_DIR})
280  endif ()
281  # set <Pkg>_<Module>_FOUND = TRUE
282  basis_set_config (${_MODULE_NAME}_FOUND TRUE)
283  # append to list of found requested modules
284  basis_append_config (MODULES_FOUND ${_MODULE_NAME})
285  endif ()
286 endforeach ()
287 unset (_PACKAGE_NS)
288 
289 if (${NS}MODULES_NOTFOUND)
290  set (_REQUIRED)
291  set (_OPTIONAL)
292  set (_MISSING)
293  foreach (_MODULE_NAME IN LISTS ${NS}MODULES_REQUESTED)
294  if (${NS}FIND_REQUIRED_${_MODULE_NAME})
295  list (APPEND _REQUIRED ${_MODULE_NAME})
296  if (NOT ${NS}${_MODULE_NAME}_FOUND)
297  list (APPEND _MISSING ${_MODULE_NAME})
298  endif ()
299  else ()
300  list (APPEND _OPTIONAL ${_MODULE_NAME})
301  endif ()
302  endforeach ()
303  if (_MISSING)
304  message(FATAL_ERROR "Could not find all required MIRTK components!"
305  " Rebuild and/or install the MIRTK package with"
306  " the following modules enabled by setting MODULE_<name>"
307  " to ON when configuring the build of the package with CMake."
308  "\nOptional modules = [${_OPTIONAL}]"
309  "\nRequired modules = [${_REQUIRED}]"
310  "\nMissing modules = [${_MISSING}]\n")
311  endif ()
312  unset (_REQUIRED)
313  unset (_OPTIONAL)
314  unset (_MISSING)
315 endif ()
316 
317 unset (_MODULE_NAME)
318 unset (_MODULE_IDX)
319 unset (_MODULE_NS)
320 
321 # ============================================================================
322 # clean INCLUDE_DIRS and LIBRARY_DIRS
323 # ============================================================================
324 
325 basis_remove_duplicates_config (INCLUDE_DIR)
326 basis_remove_duplicates_config (INCLUDE_DIRS)
327 basis_remove_duplicates_config (LIBRARY_DIR)
328 basis_remove_duplicates_config (LIBRARY_DIRS)
329 
330 basis_remove_item_config (INCLUDE_DIRS "")
331 basis_remove_item_config (LIBRARY_DIRS "")
332 
333 # ============================================================================
334 # dependencies
335 # ============================================================================
336 
337 
338 
339 # ============================================================================
340 # CMake Modules
341 # ============================================================================
342 
343 ## @brief Directory containing the CMake BASIS Modules
344 set(BASIS_MODULE_PATH "/Users/as12312/Software/MIRTK/Maintenance/CMake/Basis")
345 
346 if (EXISTS "${BASIS_MODULE_PATH}/BasisTools.cmake")
347  set(MIRTK_BASIS_FOUND TRUE)
348 else ()
349  set(MIRTK_BASIS_FOUND FALSE)
350 endif ()
351 if (NOT MIRTK_BASIS_FOUND AND (MIRTK_FIND_REQUIRED_BASIS OR MIRTK_FIND_REQUIRED_CMake))
352  message (FATAL_ERROR "Required CMake BASIS Modules of package MIRTK"
353  " could not be found in ${BASIS_MODULE_PATH}!")
354 endif ()
355 
356 ## @brief Directory containing the MIRTK CMake Modules
357 set(MIRTK_MODULE_PATH "/Users/as12312/Software/MIRTK/Maintenance/CMake/Modules")
358 
359 if (EXISTS "${MIRTK_MODULE_PATH}/mirtkTools.cmake")
360  set(MIRTK_CMake_FOUND TRUE)
361 else ()
362  set(MIRTK_CMake_FOUND FALSE)
363 endif ()
364 if (NOT MIRTK_CMake_FOUND AND MIRTK_FIND_REQUIRED_CMake)
365  message (FATAL_ERROR "Required CMake Modules of package MIRTK"
366  " could not be found in ${MIRTK_MODULE_PATH}!")
367 endif ()
368 if (NOT MIRTK_BASIS_FOUND)
369  set(MIRTK_CMake_FOUND FALSE)
370 endif ()
371 
372 # include requested CMake modules
373 if (_INCLUDE_BASIS_MODULES OR _INCLUDE_CMake_MODULES)
374  if (MIRTK_CMake_FOUND)
375  list(APPEND CMAKE_MODULE_PATH "${MIRTK_MODULE_PATH}")
376  endif ()
377  if (MIRTK_BASIS_FOUND)
378  list(APPEND CMAKE_MODULE_PATH "${BASIS_MODULE_PATH}")
379  endif ()
380  if (_INCLUDE_CMake_MODULES AND MIRTK_CMake_FOUND)
381  include(mirtkPolicies NO_POLICY_SCOPE)
382  endif ()
383  if (MIRTK_BASIS_FOUND)
384  include(BasisSettings)
385  include(BasisTools)
386  endif ()
387  if (_INCLUDE_CMake_MODULES AND MIRTK_CMake_FOUND)
388  include(mirtkTools)
389  endif ()
390 endif ()
391 
392 unset(_INCLUDE_BASIS_MODULES)
393 unset(_INCLUDE_CMake_MODULES)
394 
395 # ============================================================================
396 # Common settings
397 # ============================================================================
398 
399 ## @brief Directory containing the MIRTK command executables
400 set(MIRTK_TOOLS_DIR "")
401 
402 ## @brief Whether to build shared libraries by default
403 if (NOT DEFINED BUILD_SHARED_LIBS_DEFAULT)
404  set(BUILD_SHARED_LIBS_DEFAULT ON)
405 endif ()
406 
407 ## @brief Whether to enable profiling of code execution by default
408 if (NOT DEFINED WITH_PROFILING_DEFAULT)
409  set(WITH_PROFILING_DEFAULT ON)
410 endif ()
411 
412 ## @brief Whether to build applications by default
413 if (NOT DEFINED BUILD_APPLICATIONS_DEFAULT)
414  set(BUILD_APPLICATIONS_DEFAULT ON)
415 endif ()
416 
417 ## @brief Default for WITH_TBB
418 if (NOT DEFINED WITH_TBB_DEFAULT)
419  set(WITH_TBB_DEFAULT ON)
420 endif ()
421 
422 ## @brief Default for WITH_VTK
423 if (NOT DEFINED WITH_VTK_DEFAULT)
424  set(WITH_VTK_DEFAULT ON)
425 endif ()
426 
427 ## @brief Default for WITH_ZLIB
428 if (NOT DEFINED WITH_ZLIB_DEFAULT)
429  set(WITH_ZLIB_DEFAULT ON)
430 endif ()
431 
432 
433 ## @}
434 # end of Doxygen group - keep at end of file