CMakeFindFrameworks.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CMakeFindFrameworks
  5. -------------------
  6. .. deprecated:: 3.31
  7. This module does nothing, unless policy :policy:`CMP0173` is set to ``OLD``.
  8. helper module to find OSX frameworks
  9. This module reads hints about search locations from variables::
  10. CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
  11. #]=======================================================================]
  12. cmake_policy(GET CMP0173 _cmp0173)
  13. if(_cmp0173 STREQUAL "NEW")
  14. message(FATAL_ERROR
  15. "CMakeFindFrameworks.cmake is not maintained and lacks support for more "
  16. "recent framework handling. It will be removed in a future version of "
  17. "CMake. Update the code to use find_library() instead. "
  18. "Use of this module is now an error according to policy CMP0173."
  19. )
  20. elseif(_cmp0173 STREQUAL "")
  21. # CMake will have already emitted the standard policy warning for the point
  22. # of inclusion. We only need to add the context-specific info here.
  23. message(AUTHOR_WARNING
  24. "CMakeFindFrameworks.cmake is not maintained and lacks support for more "
  25. "recent framework handling. It will be removed in a future version of "
  26. "CMake. Update the code to use find_library() instead."
  27. )
  28. endif ()
  29. unset(_cmp0173)
  30. if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
  31. set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
  32. macro(CMAKE_FIND_FRAMEWORKS fwk)
  33. set(${fwk}_FRAMEWORKS)
  34. if(APPLE)
  35. # 'Frameworks' directory from Brew (Apple Silicon and Intel)
  36. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
  37. set(_brew_framework_path /opt/homebrew/Frameworks)
  38. else()
  39. set(_brew_framework_path /usr/local/Frameworks)
  40. endif()
  41. file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH)
  42. set(_cmff_search_paths
  43. ${CMAKE_FRAMEWORK_PATH}
  44. ${_cmff_CMAKE_FRAMEWORK_PATH}
  45. ~/Library/Frameworks
  46. ${_brew_framework_path}
  47. /Library/Frameworks
  48. /System/Library/Frameworks
  49. /Network/Library/Frameworks
  50. ${CMAKE_SYSTEM_FRAMEWORK_PATH})
  51. # For backwards compatibility reasons,
  52. # CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS includes ${fwk}.framework
  53. list(TRANSFORM _cmff_search_paths APPEND /${fwk}.framework)
  54. list(APPEND _cmff_search_paths ${CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS})
  55. list(REMOVE_DUPLICATES _cmff_search_paths)
  56. foreach(dir IN LISTS _cmff_search_paths)
  57. if(EXISTS ${dir})
  58. set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
  59. endif()
  60. endforeach()
  61. endif()
  62. endmacro()
  63. endif()