[libcxx] r271460 - [libcxx] Allow target flags to affect CMake configuration tests
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 1 18:10:09 PDT 2016
Author: ericwf
Date: Wed Jun 1 20:10:08 2016
New Revision: 271460
URL: http://llvm.org/viewvc/llvm-project?rev=271460&view=rev
Log:
[libcxx] Allow target flags to affect CMake configuration tests
Summary:
This patch changes the libc++ 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.
This patch fixes:
https://llvm.org/bugs/show_bug.cgi?id=24322
Reviewers: danalbert, jroelofs, bcraig, compnerd
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20887
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=271460&r1=271459&r2=271460&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed Jun 1 20:10:08 2016
@@ -247,6 +247,18 @@ set(LIBCXX_COMPILE_FLAGS "")
set(LIBCXX_LINK_FLAGS "")
set(LIBCXX_LIBRARIES "")
+# Include macros for adding and removing libc++ flags.
+include(HandleLibcxxFlags)
+
+# Target flags ================================================================
+# These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that
+# 'config-ix' use them during feature checks. It also adds them to both
+# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
+add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
+add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
+add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
+add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
+
# Configure compiler.
include(config-ix)
@@ -264,9 +276,6 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" upp
include(HandleLibCXXABI) # Setup the ABI library flags
-# Include macros for adding and removing libc++ flags.
-include(HandleLibcxxFlags)
-
# Remove flags that may have snuck in.
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
-stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
@@ -288,11 +297,6 @@ endif()
# headers
add_compile_flags_if_supported(-nostdinc++)
-# Target flags ================================================================
-add_flags_if(LIBCXX_BUILD_32_BITS -m32)
-add_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
-add_flags_if(LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
-add_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
# Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Modified: libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake?rev=271460&r1=271459&r2=271460&view=diff
==============================================================================
--- libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibcxxFlags.cmake Wed Jun 1 20:10:08 2016
@@ -76,6 +76,26 @@ macro(config_define value def)
set(LIBCXX_NEEDS_SITE_CONFIG ON)
endmacro()
+# Add a list of flags to all of 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS',
+# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'.
+macro(add_target_flags)
+ foreach(value ${ARGN})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${value}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${value}")
+ list(APPEND LIBCXX_COMPILE_FLAGS ${value})
+ list(APPEND LIBCXX_LINK_FLAGS ${value})
+ endforeach()
+endmacro()
+
+# If the specified 'condition' is true then add a list of flags to
+# all of 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', 'LIBCXX_COMPILE_FLAGS'
+# and 'LIBCXX_LINK_FLAGS'.
+macro(add_target_flags_if condition)
+ if (${condition})
+ add_target_flags(${ARGN})
+ endif()
+endmacro()
+
# Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and
# 'LIBCXX_LINK_FLAGS'.
macro(add_flags)
More information about the cfe-commits
mailing list