[llvm] r200744 - [CMake] Add -stdlib=libc++ to host Clang build flags before performing any header search
Alexey Samsonov
samsonov at google.com
Mon Feb 3 23:55:19 PST 2014
Author: samsonov
Date: Tue Feb 4 01:55:18 2014
New Revision: 200744
URL: http://llvm.org/viewvc/llvm-project?rev=200744&view=rev
Log:
[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.
Modified:
llvm/trunk/CMakeLists.txt
llvm/trunk/cmake/config-ix.cmake
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=200744&r1=200743&r2=200744&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Tue Feb 4 01:55:18 2014
@@ -272,6 +272,14 @@ option (LLVM_BUILD_DOCS "Build the llvm
option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON)
option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm documentation." OFF)
+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()
+
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=200744&r1=200743&r2=200744&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Tue Feb 4 01:55:18 2014
@@ -34,6 +34,25 @@ function(check_type_exists type files va
" ${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)
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200744&r1=200743&r2=200744&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Feb 4 01:55:18 2014
@@ -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)
More information about the llvm-commits
mailing list