From 2dd67c7ea095957d557d2934a67baacdf8a82d7b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Dec 2012 11:49:13 -0500 Subject: 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 commit efaf335b (Skip implicit link information on Xcode, 2009-07-23) and commit 5195a664 (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. --- Modules/CMakeDetermineCompilerABI.cmake | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'Modules/CMakeDetermineCompilerABI.cmake') diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 75247d9558..cb94aa6559 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -72,18 +72,7 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) # Parse implicit linker information for this language, if available. set(implicit_dirs "") set(implicit_libs "") - set(MULTI_ARCH FALSE) - if(DEFINED CMAKE_OSX_ARCHITECTURES) - if( "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" ) - set(MULTI_ARCH TRUE) - endif() - endif() - if(CMAKE_${lang}_VERBOSE_FLAG - # Implicit link information cannot be used explicitly for - # multiple OS X architectures, so we skip it. - AND NOT MULTI_ARCH - # Skip this with Xcode for now. - AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode) + if(CMAKE_${lang}_VERBOSE_FLAG) CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log "${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -112,6 +101,14 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) message(STATUS "${_desc}") endif() + # Implicit link libraries cannot be used explicitly for multiple + # OS X architectures, so we skip it. + if(DEFINED CMAKE_OSX_ARCHITECTURES) + if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ";") + set(implicit_libs "") + endif() + endif() + set(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) set(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) -- cgit v1.2.1