File: CMakeFindFrameworks.cmake

package info (click to toggle)
cmake 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 147,284 kB
  • sloc: ansic: 403,915; cpp: 290,772; sh: 4,102; python: 3,357; yacc: 3,106; lex: 1,189; f90: 532; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 230; perl: 217; objc: 215; xml: 198; makefile: 97; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (74 lines) | stat: -rw-r--r-- 2,763 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file LICENSE.rst or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
CMakeFindFrameworks
-------------------

.. deprecated:: 3.31
  This module does nothing, unless policy :policy:`CMP0173` is set to ``OLD``.

helper module to find OSX frameworks

This module reads hints about search locations from variables::

  CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
#]=======================================================================]

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)

if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
  set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
  macro(CMAKE_FIND_FRAMEWORKS fwk)
    set(${fwk}_FRAMEWORKS)
    if(APPLE)
      # '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()

      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
            ${_brew_framework_path}
            /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)
        if(EXISTS ${dir})
          set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir})
        endif()
      endforeach()
    endif()
  endmacro()
endif()