Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionCheckModuleDependencies.cmake
Go to the documentation of this file.
1 #! Checks if all required modules and packages exist and stores missing
2 #! dependencies in <missing_deps>.
3 #!
4 #! Usage:
5 #!
6 #! mitk_check_module_dependencies(
7 #! MODULES <module-list>
8 #! PACKAGES <package-list>
9 #! MISSING_DEPENDENCIES_VAR <missing_deps>
10 #! MODULE_DEPENDENCIES_VAR <module_deps>
11 #! PACKAGE_DEPENDENCIES_VAR <package_deps>)
12 #!
14 
15  set(_macro_params
16  MISSING_DEPENDENCIES_VAR # variable for storing missing dependencies
17  MODULE_DEPENDENCIES_VAR # variable for storing all module dependencies
18  PACKAGE_DEPENDENCIES_VAR # variable for storing all package dependencies
19  )
20 
21  set(_macro_multiparams
22  MODULES # MITK modules which the given TARGET uses
23  PACKAGES # MITK packages which the given TARGET uses
24  )
25 
26  set(_macro_options )
27 
28  cmake_parse_arguments(CHECK "" "${_macro_params}" "${_macro_multiparams}" ${ARGN})
29 
30  set(missing_deps )
31  set(depends ${CHECK_MODULES})
32  set(package_depends ${CHECK_PACKAGES})
33  set(module_names )
34  set(package_names )
35 
36  foreach(dep ${depends})
37  if(NOT dep STREQUAL "PUBLIC" AND NOT dep STREQUAL "PRIVATE" AND NOT dep STREQUAL "INTERFACE")
38  if(NOT TARGET ${dep})
39  list(APPEND missing_deps ${dep})
40  endif()
41  list(APPEND module_names ${dep})
42  endif()
43  endforeach()
44 
45  set(package_names)
46  if(package_depends)
47  _mitk_parse_package_args(${package_depends})
48  set(package_names ${PUBLIC_PACKAGE_NAMES} ${PRIVATE_PACKAGE_NAMES} ${INTERFACE_PACKAGE_NAMES})
49  list(REMOVE_DUPLICATES package_names)
50  foreach(_package ${package_names})
51  if((DEFINED MITK_USE_${_package}) AND NOT (${MITK_USE_${_package}}))
52  list(APPEND missing_deps ${_package})
53  endif()
54  endforeach()
55  endif()
56 
57  if(missing_deps)
58  list(REMOVE_DUPLICATES missing_deps)
59  if(CHECK_MISSING_DEPENDENCIES_VAR)
60  set(${CHECK_MISSING_DEPENDENCIES_VAR} ${missing_deps} PARENT_SCOPE)
61  endif()
62  endif()
63  if(CHECK_MODULE_DEPENDENCIES_VAR)
64  set(${CHECK_MODULE_DEPENDENCIES_VAR} ${module_names} PARENT_SCOPE)
65  endif()
66  if(CHECK_PACKAGE_DEPENDENCIES_VAR)
67  set(${CHECK_PACKAGE_DEPENDENCIES_VAR} ${package_names} PARENT_SCOPE)
68  endif()
69 endfunction()
mitk_check_module_dependencies()
const std::string TARGET