1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
8 helper module to find OSX frameworks
10 This module reads hints about search locations from variables::
12 CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
13 #]=======================================================================]
15 if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
16 set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
17 macro(CMAKE_FIND_FRAMEWORKS fwk)
18 set(${fwk}_FRAMEWORKS)
20 # 'Frameworks' directory from Brew (Apple Silicon and Intel)
21 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
22 set(_brew_framework_path /opt/homebrew/Frameworks)
24 set(_brew_framework_path /usr/local/Frameworks)
27 file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH)
28 set(_cmff_search_paths
29 ${CMAKE_FRAMEWORK_PATH}
30 ${_cmff_CMAKE_FRAMEWORK_PATH}
32 ${_brew_framework_path}
34 /System/Library/Frameworks
35 /Network/Library/Frameworks
36 ${CMAKE_SYSTEM_FRAMEWORK_PATH})
38 # For backwards compatibility reasons,
39 # CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS includes ${fwk}.framework
40 list(TRANSFORM _cmff_search_paths APPEND /${fwk}.framework)
41 list(APPEND _cmff_search_paths ${CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS})
43 list(REMOVE_DUPLICATES _cmff_search_paths)
45 foreach(dir IN LISTS _cmff_search_paths)
47 set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})