summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerABI.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-07-23 14:07:25 (GMT)
committerBrad King <brad.king@kitware.com>2009-07-23 14:07:25 (GMT)
commit07ea19ad1f280e7a1cb07ab2b52c0081f72251dd (patch)
tree3844b6660772215cdae9420ddcfa3574be35e8db /Modules/CMakeDetermineCompilerABI.cmake
parent797e49a1cc53fb120fad286665c875075eb18361 (diff)
downloadCMake-07ea19ad1f280e7a1cb07ab2b52c0081f72251dd.zip
CMake-07ea19ad1f280e7a1cb07ab2b52c0081f72251dd.tar.gz
CMake-07ea19ad1f280e7a1cb07ab2b52c0081f72251dd.tar.bz2
ENH: Implicit link info for C, CXX, and Fortran
This teaches CMake to detect implicit link information for C, C++, and Fortran compilers. We detect the implicit linker search directories and implicit linker options for UNIX-like environments using verbose output from compiler front-ends. We store results in new variables called CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES The implicit libraries can contain linker flags as well as library names.
Diffstat (limited to 'Modules/CMakeDetermineCompilerABI.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 3fd06a9..d519237 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -3,6 +3,8 @@
# This is used internally by CMake and should not be included by user
# code.
+INCLUDE(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+
FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
IF(NOT DEFINED CMAKE_DETERMINE_${lang}_ABI_COMPILED)
MESSAGE(STATUS "Detecting ${lang} compiler ABI info")
@@ -11,6 +13,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin")
TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
${CMAKE_BINARY_DIR} ${src}
+ CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}"
+ "-DCMAKE_${lang}_STANDARD_LIBRARIES="
OUTPUT_VARIABLE OUTPUT
COPY_FILE "${BIN}"
)
@@ -40,6 +44,15 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
SET(CMAKE_INTERNAL_PLATFORM_ABI "${ABI_NAME}" PARENT_SCOPE)
ENDIF(ABI_NAME)
+ # Parse implicit linker information for this language, if available.
+ SET(implicit_dirs "")
+ SET(implicit_libs "")
+ IF(CMAKE_${lang}_VERBOSE_FLAG)
+ CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs)
+ ENDIF()
+ SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE)
+ SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)
+
ELSE(CMAKE_DETERMINE_${lang}_ABI_COMPILED)
MESSAGE(STATUS "Detecting ${lang} compiler ABI info - failed")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log