mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 15:18:26 -05:00
OS X: Detect implicit linker framework search paths
Previously we hard-coded a list of implicit framework directories but did not account for CMAKE_OSX_SYSROOT or for changes to the list across OS X versions. Instead we should automatically detect the framework directories for the active toolchain. The parent commit added the "-Wl,-v" option to ask "ld" to print its implicit directories. It displays a block such as: Framework search paths: /... Parse this block to extract the list of framework directories. Detection may fail on toolchains that do not list their framework directories, such as older OS X linkers. Always treat the paths <sdk>/Library/Frameworks <sdk>/System/Library/Frameworks <sdk>/Network/Library/Frameworks # Older OS X only /System/Library/Frameworks as implicit. Note that /System/Library/Frameworks should always be considered implicit so that frameworks CMake finds there will not override the SDK copies.
This commit is contained in:
@@ -256,6 +256,24 @@ set(CMAKE_CXX_CREATE_MACOSX_FRAMEWORK
|
||||
if(NOT DEFINED CMAKE_FIND_FRAMEWORK)
|
||||
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||
endif()
|
||||
|
||||
# Older OS X linkers do not report their framework search path
|
||||
# with -v but "man ld" documents the following locations.
|
||||
set(CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
|
||||
${_CMAKE_OSX_SYSROOT_PATH}/Library/Frameworks
|
||||
${_CMAKE_OSX_SYSROOT_PATH}/System/Library/Frameworks
|
||||
)
|
||||
if(_CMAKE_OSX_SYSROOT_PATH)
|
||||
# Treat some paths as implicit so we do not override the SDK versions.
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
|
||||
/System/Library/Frameworks)
|
||||
endif()
|
||||
if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
|
||||
# Older OS X tools had more implicit paths.
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
|
||||
${_CMAKE_OSX_SYSROOT_PATH}/Network/Library/Frameworks)
|
||||
endif()
|
||||
|
||||
# set up the default search directories for frameworks
|
||||
set(CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
~/Library/Frameworks
|
||||
|
||||
Reference in New Issue
Block a user