cmake/Modules/CMakeFindFrameworks.cmake

75 lines
2.7 KiB
CMake
Raw Normal View History

2016-10-30 18:24:19 +01:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
2019-11-11 23:01:05 +01:00
#[=======================================================================[.rst:
CMakeFindFrameworks
-------------------
2024-11-11 15:18:55 +01:00
.. deprecated:: 3.31
This module does nothing, unless policy :policy:`CMP0173` is set to ``OLD``.
2019-11-11 23:01:05 +01:00
helper module to find OSX frameworks
This module reads hints about search locations from variables::
CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
#]=======================================================================]
2009-10-04 10:30:41 +03:00
2024-11-11 15:18:55 +01:00
cmake_policy(GET CMP0173 _cmp0173)
if(_cmp0173 STREQUAL "NEW")
message(FATAL_ERROR
"CMakeFindFrameworks.cmake is not maintained and lacks support for more "
"recent framework handling. It will be removed in a future version of "
"CMake. Update the code to use find_library() instead. "
"Use of this module is now an error according to policy CMP0173."
)
elseif(_cmp0173 STREQUAL "")
# CMake will have already emitted the standard policy warning for the point
# of inclusion. We only need to add the context-specific info here.
message(AUTHOR_WARNING
"CMakeFindFrameworks.cmake is not maintained and lacks support for more "
"recent framework handling. It will be removed in a future version of "
"CMake. Update the code to use find_library() instead."
)
endif ()
unset(_cmp0173)
2013-03-16 19:13:01 +02:00
if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
macro(CMAKE_FIND_FRAMEWORKS fwk)
set(${fwk}_FRAMEWORKS)
if(APPLE)
2022-11-16 20:14:03 +01:00
# 'Frameworks' directory from Brew (Apple Silicon and Intel)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(_brew_framework_path /opt/homebrew/Frameworks)
else()
set(_brew_framework_path /usr/local/Frameworks)
endif()
2020-08-30 11:54:41 +02:00
file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH)
set(_cmff_search_paths
${CMAKE_FRAMEWORK_PATH}
${_cmff_CMAKE_FRAMEWORK_PATH}
~/Library/Frameworks
2022-11-16 20:14:03 +01:00
${_brew_framework_path}
2020-08-30 11:54:41 +02:00
/Library/Frameworks
/System/Library/Frameworks
/Network/Library/Frameworks
${CMAKE_SYSTEM_FRAMEWORK_PATH})
# For backwards compatibility reasons,
# CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS includes ${fwk}.framework
list(TRANSFORM _cmff_search_paths APPEND /${fwk}.framework)
list(APPEND _cmff_search_paths ${CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS})
list(REMOVE_DUPLICATES _cmff_search_paths)
foreach(dir IN LISTS _cmff_search_paths)
2013-03-16 19:13:01 +02:00
if(EXISTS ${dir})
set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
endif()
endforeach()
endif()
endmacro()
endif()