mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
8d0fafd361
It is sometimes useful to have the C++ standard library linked into the assembly when compiling clang, particularly when distributing a compiler onto systems that don't have a copy of stdlibc++ or libc++ installed. This functionality should work with either GCC or Clang as the host compiler, though statically linking libc++ (as may be required for licensing purposes) is only possible if the host compiler is Clang with a copy of libc++ available. Differential Revision: https://reviews.llvm.org/D65603 llvm-svn: 368907
55 lines
1.8 KiB
CMake
55 lines
1.8 KiB
CMake
# This CMake module is responsible for setting the standard library to libc++
|
|
# if the user has requested it.
|
|
|
|
include(DetermineGCCCompatible)
|
|
|
|
if(NOT DEFINED LLVM_STDLIB_HANDLED)
|
|
set(LLVM_STDLIB_HANDLED ON)
|
|
|
|
function(append value)
|
|
foreach(variable ${ARGN})
|
|
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
|
|
endforeach(variable)
|
|
endfunction()
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
include(CheckLinkerFlag)
|
|
set(LLVM_LIBCXX_USED 0)
|
|
if(LLVM_ENABLE_LIBCXX)
|
|
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
|
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
|
|
check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
|
|
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
|
|
append("-stdlib=libc++"
|
|
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
|
|
CMAKE_MODULE_LINKER_FLAGS)
|
|
set(LLVM_LIBCXX_USED 1)
|
|
else()
|
|
message(WARNING "Can't specify libc++ with '-stdlib='")
|
|
endif()
|
|
else()
|
|
message(WARNING "Not sure how to specify libc++ for this compiler")
|
|
endif()
|
|
endif()
|
|
|
|
if(LLVM_STATIC_LINK_CXX_STDLIB)
|
|
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
|
check_cxx_compiler_flag("-static-libstdc++"
|
|
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
|
|
check_linker_flag("-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
|
|
if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
|
|
CXX_LINKER_SUPPORTS_STATIC_STDLIB)
|
|
append("-static-libstdc++"
|
|
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
|
|
CMAKE_MODULE_LINKER_FLAGS)
|
|
else()
|
|
message(WARNING
|
|
"Can't specify static linking for the C++ standard library")
|
|
endif()
|
|
else()
|
|
message(WARNING "Not sure how to specify static linking of C++ standard "
|
|
"library for this compiler")
|
|
endif()
|
|
endif()
|
|
endif()
|