summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeFindFrameworks.cmake
blob: 8906f48f3a12d89776bbe3a28edd95e7713954ae (plain)
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
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

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

helper module to find OSX frameworks

This module reads hints about search locations from variables::

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

if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
  set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
  macro(CMAKE_FIND_FRAMEWORKS fwk)
    set(${fwk}_FRAMEWORKS)
    if(APPLE)
      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
            /usr/local/Frameworks
            /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()