summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-11-13 00:35:23 +0000
committerHans Wennborg <hans@hanshq.net>2014-11-13 00:35:23 +0000
commit94a9396ff7f0e33ac112038deec844d6fc94d0e8 (patch)
tree6656589e39597977d72e33308fdc474d84a0389e /CMakeLists.txt
parent44575a006feadea04b2a5b6f49a32f73ebaa68a1 (diff)
CMake: Set HOST_LINK_VERSION on Darwin (PR21268)
The Autoconf build already does this, but it was never ported to CMake. The host linker version affects the flags that Clang pass to the linker, notably whether it passes -demangle or not. http://reviews.llvm.org/D6239 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221844 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt20
1 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbff5add48..fe0d5f2621 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -253,6 +253,26 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
endif()
endif ()
+# Determine HOST_LINK_VERSION on Darwin.
+set(HOST_LINK_VERSION)
+if (APPLE)
+ set(LD_V_OUTPUT)
+ execute_process(
+ COMMAND sh -c "${CMAKE_LINKER} -v 2>&1 | head -1"
+ RESULT_VARIABLE HAD_ERROR
+ OUTPUT_VARIABLE LD_V_OUTPUT
+ )
+ if (NOT HAD_ERROR)
+ if ("${LD_V_OUTPUT}" MATCHES ".*ld64.*")
+ string(REGEX REPLACE ".*ld64-([0-9.]*).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+ else()
+ string(REGEX REPLACE "[^0-9]*([0-9.]*).*" "\\1" HOST_LINK_VERSION ${LD_V_OUTPUT})
+ endif()
+ else()
+ message(FATAL_ERROR "${CMAKE_LINKER} failed with status ${HAD_ERROR}")
+ endif()
+endif()
+
configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h)