diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-06-02 01:02:10 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-06-02 01:02:10 +0000 |
commit | 3c67fad597f9709c518edb67520eea803588b011 (patch) | |
tree | 1b58b2d7863dc0ecbd6ba277cc4a90b7ea7744c2 /libunwind/CMakeLists.txt | |
parent | fb2c571d54a62d9b0ee8d5d6f9eb9f4954904ebe (diff) |
[libunwind] Allow target flags to affect CMake configuration tests
Summary:
This patch changes the libunwind CMake so that it adds certain target flags like '-m32' or '--gcc-toolchain' before including config-ix.cmake.
Since these flags can affect things like check_library_exists([...]) they needed to be added before the tests are performed.
Additionally this patch adds LIBUNWIND_BUILD_32_BITS which defaults to LLVM_BUILD_32_BITS.
This patch fixes:
https://llvm.org/bugs/show_bug.cgi?id=27950
https://llvm.org/bugs/show_bug.cgi?id=27959
Reviewers: jroelofs, danalbert, bcraig, rmaprath, compnerd
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20889
Diffstat (limited to 'libunwind/CMakeLists.txt')
-rw-r--r-- | libunwind/CMakeLists.txt | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 7ed1f10484f..d5ad2f9ea97 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -99,14 +99,16 @@ endif() #=============================================================================== # Define options. +option(LIBUNWIND_BUILD_32_BITS "Build 32 bit libunwind" ${LLVM_BUILD_32_BITS}) option(LIBUNWIND_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) option(LIBUNWIND_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LIBUNWIND_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBUNWIND_ENABLE_SHARED "Build libunwind as a shared library." ON) option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF) -set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.") -set(LIBUNWIND_SYSROOT "" CACHE STRING "Sysroot for cross compiling.") +set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") +set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") +set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") #=============================================================================== # Configure System @@ -117,17 +119,15 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -# Configure compiler. -include(config-ix) - set(LIBUNWIND_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBUNWIND_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBUNWIND_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) -#=============================================================================== -# Setup Compiler Flags -#=============================================================================== +set(LIBUNWIND_C_FLAGS "") +set(LIBUNWIND_CXX_FLAGS "") +set(LIBUNWIND_COMPILE_FLAGS "") +set(LIBUNWIND_LINK_FLAGS "") # Get required flags. macro(append_if list condition var) @@ -136,10 +136,29 @@ macro(append_if list condition var) endif() endmacro() -set(LIBUNWIND_C_FLAGS "") -set(LIBUNWIND_CXX_FLAGS "") -set(LIBUNWIND_COMPILE_FLAGS "") -set(LIBUNWIND_LINK_FLAGS "") +macro(add_target_flags_if condition var) + if (${condition}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${var}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${var}") + list(APPEND LINUNWIND_COMPILE_FLAGS ${var}) + list(APPEND LIBUNWIND_LINK_FLAGS ${var}) + endif() +endmacro() + +add_target_flags_if(LIBUNWIND_BUILD_32_BITS "-m32") +add_target_flags_if(LIBUNWIND_TARGET_TRIPLE + "-target ${LIBUNWIND_TARGET_TRIPLE}") +add_target_flags_if(LIBUNWIND_GCC_TOOLCHAIN + "-gcc-toolchain ${LIBUNWIND_GCC_TOOLCHAIN}") +add_target_flags_if(LIBUNWIND_SYSROOT + "--sysroot=${LIBUNWIND_SYSROOT}") + +# Configure compiler. +include(config-ix) + +#=============================================================================== +# Setup Compiler Flags +#=============================================================================== append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_WERROR_FLAG -Werror=return-type) @@ -213,13 +232,6 @@ if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif () -append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_TARGET_TRIPLE - "-target ${LIBUNWIND_TARGET_TRIPLE}") -append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_GCC_TOOLCHAIN - "-gcc-toolchain ${LIBUNWIND_GCC_TOOLCHAIN}") -append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_SYSROOT - "--sysroot=${LIBUNWIND_SYSROOT}") - #=============================================================================== # Setup Source Code #=============================================================================== |