Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / CMakeFindFrameworks.cmake
blob1aa3929478f25f09b4e3a14141e8c79555428e78
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:
5 CMakeFindFrameworks
6 -------------------
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)
19     if(APPLE)
20       # 'Frameworks' directory from Brew (Apple Silicon and Intel)
21       if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
22         set(_brew_framework_path /opt/homebrew/Frameworks)
23       else()
24         set(_brew_framework_path /usr/local/Frameworks)
25       endif()
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}
31             ~/Library/Frameworks
32             ${_brew_framework_path}
33             /Library/Frameworks
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)
46         if(EXISTS ${dir})
47           set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
48         endif()
49       endforeach()
50     endif()
51   endmacro()
52 endif()