1 #! Register an external project. 3 #! Calling this function registers an external project with the MITK 4 #! build system. Usage: 6 #! mitkFunctionAddExternalProject(NAME name [ON|OFF] 7 #! [PACKAGE package] [COMPONENTS comp1...] 10 #! [NO_CACHE] [ADVANCED] [NO_PACKAGE] 13 #! The function creates a MITK_USE_<name> internal cache variable if the 14 #! NO_CACHE option is given. If the NO_CACHE option is not set, a normal 15 #! boolean cache option is created with the given DOC argument as help string. 16 #! The option is marked as advanced if the ADVANCED option is set. The 17 #! option's initial value matches the ON or OFF option and defaults to OFF 18 #! if none is given. The DEPENDS arguments are used to force the 19 #! corresponding MITK_USE_<depN> cache variables to ON if MITK_USE_<name> 22 #! The PACKAGE argument names the argument for the 23 #! corresponding find_package() call in MITKs top-level CMakeLists.txt 24 #! and MITKConfig.cmake file. It defaults to <name>. If COMPONENTS are 25 #! specified, these are passed to the find_package() call. If the 26 #! NO_PACKAGE option is given, the find_package() call is suppressed. 28 #! For each registered external project there must exist a file called 29 #! CMakeExternals/<name>.cmake which defines the build process for 30 #! the external project. 32 #! \note Note that multiple calls of this function must be ordered 33 #! relative to their declared dependencies. This applies to the DEPENDS 34 #! arguments of this function as well as the actual target dependencies 35 #! declared in the CMakeExternals/<name>.cmake file. 38 cmake_parse_arguments(EP
"ON;OFF;NO_CACHE;ADVANCED;NO_PACKAGE" "NAME;DOC;PACKAGE" "DEPENDS;COMPONENTS" ${ARGN})
40 message(SEND_ERROR
"The NAME argument is missing.")
42 set_property(GLOBAL APPEND PROPERTY MITK_EXTERNAL_PROJECTS ${EP_NAME})
44 set(EP_DOC
"Use ${EP_NAME}")
46 if(NOT EP_PACKAGE AND NOT EP_NO_PACKAGE)
47 set(EP_PACKAGE ${EP_NAME})
50 set(_use_var
"MITK_USE_${EP_NAME}")
52 if(DEFINED ${_use_var})
53 set(_on ${${_use_var}})
58 if(_on AND EP_DEPENDS)
59 # Get all transitive dependencies 61 set(_depends_cur ${EP_DEPENDS})
62 list(REMOVE_DUPLICATES _depends_cur)
63 set(_depends_new ${_depends_cur})
64 while(NOT
"${_depends_all}" STREQUAL
"${_depends_cur}")
65 list(APPEND _depends_all ${_depends_new})
66 set(_depends_new_tmp )
67 foreach(dep ${_depends_new})
68 get_property(_dep_dep GLOBAL PROPERTY MITK_${dep}_DEPENDS)
69 list(APPEND _depends_new_tmp ${_dep_dep})
71 set(_depends_new ${_depends_new_tmp})
73 list(REMOVE_DUPLICATES _depends_new)
74 list(APPEND _depends_cur ${_depends_new})
77 # Force dependencies to ON 78 foreach(dep ${_depends_all})
79 if(NOT MITK_USE_${dep})
80 get_property(_depends_doc CACHE MITK_USE_${dep} PROPERTY HELPSTRING)
81 get_property(_depends_type CACHE MITK_USE_${dep} PROPERTY TYPE)
82 if(NOT TYPE STREQUAL
"INTERNAL")
83 # This is a cache UI variable 84 message(
"> Forcing MITK_USE_${dep} to ON because of ${_use_var}")
85 set(MITK_USE_${dep} ON CACHE BOOL
"${_depends_doc}" FORCE)
87 # This is an internal cache variable 88 set(MITK_USE_${dep} ON CACHE INTERNAL
"${_depends_doc}" FORCE)
94 # Set the actual MITK_USE_<name> cache variable 96 set(${_use_var} ${_on} CACHE INTERNAL
"${EP_DOC}" FORCE)
98 option(${_use_var}
"${EP_DOC}" ${_on})
99 #
set(${_use_var} ${_on} CACHE BOOL
"${EP_DOC}" FORCE)
101 mark_as_advanced(${_use_var})
104 set_property(GLOBAL PROPERTY MITK_${EP_NAME}_PACKAGE ${EP_PACKAGE})
105 set_property(GLOBAL PROPERTY MITK_${EP_NAME}_COMPONENTS
"${EP_COMPONENTS}")
106 set_property(GLOBAL PROPERTY MITK_${EP_NAME}_DEPENDS
"${EP_DEPENDS}")
mitkFunctionAddExternalProject()