Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroFindDependency.cmake
Go to the documentation of this file.
1 #! Wraps a find_package call by forwarding QUIET and REQUIRED arguments
2 #! from within the MITKConfig.cmake file.
3 #!
4 #! mitkMacroFindDependency(<dep> [args])
5 #!
7 
8  set(_mitk_fd_dep ${dep})
9  if(NOT _mitk_fd_dep)
10  message(FATAL_ERROR "Missing argument.")
11  endif()
12 
13  string(TOUPPER "${_mitk_fd_dep}" _mitk_fd_dep_uc)
14 
15  if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
16  set(_mitk_fd_quiet_arg QUIET)
17  endif()
18  set(_mitk_fd_required_arg)
19  if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
20  set(_mitk_fd_required_arg REQUIRED)
21  endif()
22 
23  get_property(_mitk_fd_is_transitive GLOBAL PROPERTY
24  _CMAKE_${_mitk_fd_dep}_TRANSITIVE_DEPENDENCY
25  )
26 
27  # Prefer config mode first because it finds external
28  # <proj>Config.cmake files pointed at by <proj>_DIR variables.
29  # Otherwise, existing Find<proj>.cmake files could fail.
30  # (e.g. in the case of GLEW and the FindGLEW.cmake file shipped
31  # with CMake).
32  find_package(${_mitk_fd_dep} ${ARGN}
33  QUIET
34  CONFIG
35  )
36  if(NOT (${_mitk_fd_dep}_FOUND OR ${_mitk_fd_dep_uc}_FOUND))
37  find_package(${_mitk_fd_dep} ${ARGN}
38  ${cmake_fd_quiet_arg}
39  ${cmake_fd_required_arg}
40  )
41  endif()
42 
43  if(NOT DEFINED _mitk_fd_is_transitive OR _mitk_fd_is_transitive)
44  set_property(GLOBAL PROPERTY _CMAKE_${_mitk_fd_dep}_TRANSITIVE_DEPENDENCY TRUE)
45  endif()
46 
47  if (NOT (${_mitk_fd_dep}_FOUND OR ${_mitk_fd_dep_uc}_FOUND))
48  set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${_mitk_fd_dep} could not be found.")
49  set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
50  return()
51  endif()
52  set(_mitk_fd_required_arg)
53  set(_mitk_fd_quiet_arg)
54 
55 endmacro()
mitkMacroFindDependency(dep)