[llvm] r200811 - [CMake] Move -stdlib=libc++ handling into its own file.
Jordan Rose
jordan_rose at apple.com
Tue Feb 4 16:02:37 PST 2014
Author: jrose
Date: Tue Feb 4 18:02:37 2014
New Revision: 200811
URL: http://llvm.org/viewvc/llvm-project?rev=200811&view=rev
Log:
[CMake] Move -stdlib=libc++ handling into its own file.
r200744 moved this into cmake/config-ix.cmake, so that it would happen very
early in the build process. However, standalone builds of Clang and other
external projects never include this file (which is correct).
Now, -stdlib=libc++ and the LLVM_COMPILER_IS_GCC_COMPATIBLE option are
both set in a new include file, HandleLLVMStdlib, which is included by
both config-ix.cmake and HandleLLVMOptions.cmake. This preserves existing
behavior for projects relying on HandleLLVMOptions and still does the
right thing for builds of LLVM itself.
Added:
llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake
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=200811&r1=200810&r2=200811&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Tue Feb 4 18:02:37 2014
@@ -272,14 +272,6 @@ 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=200811&r1=200810&r2=200811&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Tue Feb 4 18:02:37 2014
@@ -11,6 +11,8 @@ include(CheckFunctionExists)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
+include(HandleLLVMStdlib)
+
if( UNIX AND NOT BEOS )
# Used by check_symbol_exists:
set(CMAKE_REQUIRED_LIBRARIES m)
@@ -34,25 +36,6 @@ 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)
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=200811&r1=200810&r2=200811&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Feb 4 18:02:37 2014
@@ -2,6 +2,7 @@
# options and executing the appropriate CMake commands to realize the users'
# selections.
+include(HandleLLVMStdlib)
include(AddLLVMDefinitions)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
Added: llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake?rev=200811&view=auto
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake (added)
+++ llvm/trunk/cmake/modules/HandleLLVMStdlib.cmake Tue Feb 4 18:02:37 2014
@@ -0,0 +1,35 @@
+# This CMake module is responsible for setting the standard library to libc++
+# if the user has requested it.
+
+if(NOT DEFINED LLVM_STDLIB_HANDLED)
+ set(LLVM_STDLIB_HANDLED ON)
+
+ 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()
+
+ function(append_if condition value)
+ if(${condition})
+ foreach(variable ${ARGN})
+ set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
+ endforeach(variable)
+ endif()
+ endfunction()
+
+ include(CheckCXXCompilerFlag)
+ if(LLVM_ENABLE_LIBCXX)
+ if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
+ 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)
+ else()
+ message(WARNING "Not sure how to specify libc++ for this compiler")
+ endif()
+ endif()
+endif()
More information about the llvm-commits
mailing list