mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-03 20:29:56 -06:00
OS X: Detect implicit link directories on modern toolchains
We detect the implicit link directories for the toolchain by adding a flag to get verbose output from the compiler front-end while linking the ABI detection binary. Newer OS X toolchains based on Clang do not add the implicit link directories with -L options to their internal invocation of "ld". Instead they use a linker that comes with the toolchain and is already configured with the proper directories. Add the "-Wl,-v" option to ask "ld" to print its implicit directories. It displays them in a block such as: Library search paths: /... Parse this block to extract the implicit link directories. While at it, remove the checks introduced by commitefaf335b(Skip implicit link information on Xcode, 2009-07-23) and commit5195a664(Skip implicit link info for multiple OS X archs, 2009-09-22). Discard the non-system link directories added by Xcode. Discard all detected implicit libraries in the multi-architecture case but keep the directories. The directories are still useful without the libraries just to suppress addition of explicit -L options for them.
This commit is contained in:
@@ -19,6 +19,7 @@ endif()
|
||||
set(__DARWIN_COMPILER_CLANG 1)
|
||||
|
||||
macro(__darwin_compiler_clang lang)
|
||||
set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
|
||||
|
||||
@@ -19,6 +19,7 @@ endif()
|
||||
set(__DARWIN_COMPILER_GNU 1)
|
||||
|
||||
macro(__darwin_compiler_gnu lang)
|
||||
set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
|
||||
# GNU does not have -shared on OS X
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||
set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||
|
||||
Reference in New Issue
Block a user