[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 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271460 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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}" uppercase_CMAKE_BUILD_TYPE)
|
||||
|
||||
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user