From caeb7f94c75dbc8fcf30607f72546c8f097d1b42 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 4 Feb 2014 07:55:18 +0000 Subject: [CMake] Add -stdlib=libc++ to host Clang build flags before performing any header search If LLVM_ENABLE_LIBCXX is specified, we should append -stdlib=libc++ to build flags as early as possible, in particular, before we check for header presence (as -stdlib=libc++ modifies header lookup rules). Otherwise we can find a header at configure time (w/o -stdlib=libc++) but fail to find it at build time (with -stdlib=libc++). See PR18569 for more details. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200744 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/config-ix.cmake | 21 +++++++++++++++++++-- cmake/modules/HandleLLVMOptions.cmake | 15 --------------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'cmake') diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index c8a8571089..c9a5044099 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -34,6 +34,25 @@ function(check_type_exists type files variable) " ${variable}) endfunction() +function(append_if condition value) + if (${condition}) + foreach(variable ${ARGN}) + set(${variable} "${${variable}} ${value}" PARENT_SCOPE) + endforeach(variable) + endif() +endfunction() + +include(CheckCXXCompilerFlag) +if( LLVM_COMPILER_IS_GCC_COMPATIBLE ) + if( LLVM_ENABLE_LIBCXX ) + check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS) + endif() +endif() + # include checks check_include_file_cxx(cxxabi.h HAVE_CXXABI_H) check_include_file(dirent.h HAVE_DIRENT_H) @@ -317,8 +336,6 @@ if (LIBXML2_FOUND) endif () endif () -include(CheckCXXCompilerFlag) - check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG) set(USE_NO_MAYBE_UNINITIALIZED 0) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 38bbd2ea7e..8e4b6bbdaf 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -6,14 +6,6 @@ include(AddLLVMDefinitions) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) -if( CMAKE_COMPILER_IS_GNUCXX ) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) -elseif( MSVC ) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF) -elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) - set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON) -endif() - if(NOT LLVM_FORCE_USE_OLD_TOOLCHAIN) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) @@ -291,13 +283,6 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11) append_if(CXX_SUPPORTS_CXX11 "-std=c++11" CMAKE_CXX_FLAGS) endif (LLVM_ENABLE_CXX11) - if(LLVM_ENABLE_LIBCXX) - check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB) - append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS) - append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS) - append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS) - append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS) - endif () endif( MSVC ) macro(append_common_sanitizer_flags) -- cgit v1.2.3