2010-12-10 20:47:54 +01:00
|
|
|
# See www/CMake.html for instructions on how to build libcxx with CMake.
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Project
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
project(libcxx CXX C)
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2015-01-26 22:56:45 +01:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
|
|
|
|
2010-12-10 20:47:54 +01:00
|
|
|
set(PACKAGE_NAME libcxx)
|
|
|
|
set(PACKAGE_VERSION trunk-svn)
|
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
|
|
|
set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
|
|
|
|
|
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
2013-09-30 11:10:01 +02:00
|
|
|
${CMAKE_MODULE_PATH}
|
2010-12-10 20:47:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Require out of source build.
|
|
|
|
include(MacroEnsureOutOfSourceBuild)
|
|
|
|
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
|
|
|
|
"${PROJECT_NAME} requires an out of source build. Please create a separate
|
|
|
|
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
|
|
|
|
)
|
|
|
|
|
2013-10-03 23:58:25 +02:00
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
2014-12-29 13:15:47 +01:00
|
|
|
set(LIBCXX_LIBDIR_SUFFIX "" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
|
|
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
|
|
|
|
|
2013-10-03 23:58:25 +02:00
|
|
|
set(LIBCXX_BUILT_STANDALONE 1)
|
2014-12-29 13:15:47 +01:00
|
|
|
else()
|
|
|
|
set(LIBCXX_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
|
2013-10-03 23:58:25 +02:00
|
|
|
endif()
|
|
|
|
|
2010-12-10 20:47:54 +01:00
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
# Define options.
|
|
|
|
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
|
|
|
|
option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
|
|
|
|
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
|
|
|
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
|
|
|
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
2014-08-16 03:35:36 +02:00
|
|
|
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
|
2010-12-10 20:47:54 +01:00
|
|
|
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
|
Add option to disable access to the global filesystem namespace.
Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.
This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:
- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
all tests that use the global filesystem namespace to break, but will
at least make all the other tests run (as get_temp_file_name will not
build anyway).
It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).
Differential revision: http://reviews.llvm.org/D8194
Reviewed by: jroelofs (thanks!)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 16:44:39 +01:00
|
|
|
option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
|
2015-03-26 15:35:46 +01:00
|
|
|
option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
|
|
|
|
option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
|
2014-12-06 22:02:58 +01:00
|
|
|
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
|
2015-06-24 10:44:38 +02:00
|
|
|
option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
|
2014-12-12 04:12:18 +01:00
|
|
|
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF)
|
2014-12-06 22:02:58 +01:00
|
|
|
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
|
|
|
|
"Build libc++ with support for a monotonic clock.
|
|
|
|
This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON)
|
2014-12-12 23:52:58 +01:00
|
|
|
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
|
2013-09-02 09:28:05 +02:00
|
|
|
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
|
2015-03-31 06:15:45 +02:00
|
|
|
option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
|
|
|
|
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
|
|
|
|
"The Profile-rt library used to build with code coverage")
|
2015-03-03 16:59:51 +01:00
|
|
|
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
2015-01-16 01:55:15 +01:00
|
|
|
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
|
|
|
|
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
|
2014-08-18 07:03:46 +02:00
|
|
|
if (LIBCXX_BUILT_STANDALONE)
|
|
|
|
set(LLVM_USE_SANITIZER "" CACHE STRING
|
|
|
|
"Define the sanitizer used to build the library and tests")
|
|
|
|
endif()
|
2010-12-10 20:47:54 +01:00
|
|
|
|
2015-03-03 16:59:51 +01:00
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
|
|
|
if (APPLE)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
|
|
|
|
else()
|
|
|
|
message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-10-07 00:13:19 +02:00
|
|
|
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
|
2014-08-08 08:53:30 +02:00
|
|
|
if (NOT LIBCXX_CXX_ABI)
|
|
|
|
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
|
|
|
|
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
|
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
|
2015-03-19 21:59:45 +01:00
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
|
2014-07-27 01:08:33 +02:00
|
|
|
set(LIBCXX_CXX_ABI_INTREE 1)
|
|
|
|
else ()
|
2014-08-08 08:53:30 +02:00
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
2014-07-27 01:08:33 +02:00
|
|
|
endif ()
|
2014-08-08 08:53:30 +02:00
|
|
|
else ()
|
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
|
|
|
|
endif ()
|
2012-11-30 22:02:29 +01:00
|
|
|
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
|
|
|
|
"Specify C++ ABI library to use." FORCE)
|
2013-08-19 23:42:07 +02:00
|
|
|
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
|
2012-11-30 22:02:29 +01:00
|
|
|
|
2015-05-16 14:44:31 +02:00
|
|
|
# Build libc++abi with libunwind. We need this option to determine whether to
|
|
|
|
# link with libunwind or libgcc_s while running the test cases.
|
|
|
|
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
|
|
|
|
|
2010-12-10 20:47:54 +01:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
2014-12-20 04:16:55 +01:00
|
|
|
set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2014-12-29 13:15:47 +01:00
|
|
|
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
|
2014-12-20 04:16:55 +01:00
|
|
|
|
2014-11-15 07:26:30 +01:00
|
|
|
# Declare libc++ configuration variables.
|
|
|
|
# They are intended for use as follows:
|
|
|
|
# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
|
|
|
|
# LIBCXX_COMPILE_FLAGS: Compile only flags.
|
|
|
|
# LIBCXX_LINK_FLAGS: Linker only flags.
|
|
|
|
set(LIBCXX_CXX_FLAGS "")
|
|
|
|
set(LIBCXX_COMPILE_FLAGS "")
|
|
|
|
set(LIBCXX_LINK_FLAGS "")
|
|
|
|
|
2014-11-15 18:25:23 +01:00
|
|
|
# Configure compiler.
|
|
|
|
include(config-ix)
|
|
|
|
# Configure ABI library
|
|
|
|
include(HandleLibCXXABI)
|
2015-03-31 06:15:45 +02:00
|
|
|
# Configure coverage options.
|
|
|
|
if (LIBCXX_GENERATE_COVERAGE)
|
|
|
|
include(CodeCoverage)
|
|
|
|
set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
|
|
|
|
endif()
|
2014-11-15 18:25:23 +01:00
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
|
|
|
|
2010-12-10 20:47:54 +01:00
|
|
|
# Get required flags.
|
|
|
|
# On all systems the system c++ standard library headers need to be excluded.
|
|
|
|
if (MSVC)
|
|
|
|
# MSVC only has -X, which disables all default includes; including the crt.
|
|
|
|
# Thus, we do nothing and hope we don't accidentally include any of the C++
|
|
|
|
# headers.
|
|
|
|
else()
|
|
|
|
if (LIBCXX_HAS_NOSTDINCXX_FLAG)
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -nostdinc++)
|
2014-06-24 22:32:11 +02:00
|
|
|
string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
2014-11-15 07:26:30 +01:00
|
|
|
string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
2014-08-16 03:35:36 +02:00
|
|
|
# If c++1y has been enabled then attempt to use it. Fail if it is no supported
|
|
|
|
# by the compiler. Otherwise choose c++11 and ensure the compiler supports it.
|
|
|
|
if (LIBCXX_ENABLE_CXX1Y)
|
|
|
|
if (LIBCXX_HAS_STDCXX1Y_FLAG)
|
|
|
|
set(LIBCXX_STD_VERSION c++1y)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "c++1y was enabled but the compiler does not support it.")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if (LIBCXX_HAS_STDCXX11_FLAG)
|
|
|
|
set(LIBCXX_STD_VERSION c++11)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "c++11 is required by libc++ but is not supported by the compiler")
|
|
|
|
endif()
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
2014-08-16 03:35:36 +02:00
|
|
|
# LIBCXX_STD_VERSION should always be set at this point.
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-std=${LIBCXX_STD_VERSION}")
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
macro(append_if list condition var)
|
|
|
|
if (${condition})
|
|
|
|
list(APPEND ${list} ${var})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Get warning flags
|
2015-07-18 22:40:46 +02:00
|
|
|
# Disable the system header pragma.
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2013-10-05 02:07:35 +02:00
|
|
|
if (NOT MSVC)
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WALL_FLAG -Wall)
|
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -Werror=return-type)
|
2013-10-05 02:07:35 +02:00
|
|
|
endif()
|
2013-10-21 17:56:35 +02:00
|
|
|
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_W_FLAG -W)
|
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
|
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
|
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
|
2010-12-10 20:47:54 +01:00
|
|
|
if (LIBCXX_ENABLE_WERROR)
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror)
|
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WX_FLAG -WX)
|
2013-10-02 09:44:19 +02:00
|
|
|
else()
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_ERROR_FLAG -Wno-error)
|
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_NO_WX_FLAG -WX-)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
if (LIBCXX_ENABLE_PEDANTIC)
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Get feature flags.
|
|
|
|
# Exceptions
|
|
|
|
if (LIBCXX_ENABLE_EXCEPTIONS)
|
|
|
|
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
|
|
# functions never throw a C++ exception.
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc)
|
2010-12-10 20:47:54 +01:00
|
|
|
else()
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_EXCEPTIONS)
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-)
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-)
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
# RTTI
|
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_RTTI)
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-)
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
# Assert
|
2012-08-05 19:37:39 +02:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
|
|
if (LIBCXX_ENABLE_ASSERTIONS)
|
2010-12-10 20:47:54 +01:00
|
|
|
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
|
|
|
if (NOT MSVC)
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -D_DEBUG)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
# On Release builds cmake automatically defines NDEBUG, so we
|
|
|
|
# explicitly undefine it:
|
|
|
|
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -UNDEBUG)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -DNDEBUG)
|
2010-12-10 20:47:54 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
2013-02-25 16:50:36 +01:00
|
|
|
# Static library
|
|
|
|
if (NOT LIBCXX_ENABLE_SHARED)
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
|
2013-02-25 16:50:36 +01:00
|
|
|
endif()
|
2010-12-10 20:47:54 +01:00
|
|
|
|
2014-12-12 04:12:18 +01:00
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
|
|
|
|
if (LIBCXX_BUILD_32_BITS)
|
|
|
|
message(STATUS "Building 32 bits executables and libraries.")
|
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-m32")
|
|
|
|
endif()
|
|
|
|
elseif(LIBCXX_BUILD_32_BITS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
|
|
|
|
endif()
|
2010-12-10 20:47:54 +01:00
|
|
|
# This is the _ONLY_ place where add_definitions is called.
|
2013-10-21 17:56:35 +02:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
2014-08-18 07:03:46 +02:00
|
|
|
endif()
|
|
|
|
|
Add option to disable access to the global filesystem namespace.
Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.
This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:
- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
all tests that use the global filesystem namespace to break, but will
at least make all the other tests run (as get_temp_file_name will not
build anyway).
It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).
Differential revision: http://reviews.llvm.org/D8194
Reviewed by: jroelofs (thanks!)
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 16:44:39 +01:00
|
|
|
# LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE configuration
|
|
|
|
if (NOT LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
|
|
|
|
endif()
|
|
|
|
|
2015-03-26 15:35:46 +01:00
|
|
|
# LIBCXX_ENABLE_STDIN configuration
|
|
|
|
if (NOT LIBCXX_ENABLE_STDIN)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_STDIN)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# LIBCXX_ENABLE_STDOUT configuration
|
|
|
|
if (NOT LIBCXX_ENABLE_STDOUT)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_STDOUT)
|
|
|
|
endif()
|
|
|
|
|
2014-12-06 22:02:58 +01:00
|
|
|
# LIBCXX_ENABLE_THREADS configuration
|
|
|
|
if (NOT LIBCXX_ENABLE_THREADS)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_THREADS)
|
|
|
|
if (NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
|
|
|
|
endif()
|
|
|
|
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON.
|
|
|
|
elseif(NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
|
|
|
|
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
|
|
|
|
endif()
|
|
|
|
|
2015-06-24 10:44:38 +02:00
|
|
|
# LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS configuration
|
|
|
|
if (NOT LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
|
|
|
|
endif()
|
|
|
|
|
2014-08-18 07:03:46 +02:00
|
|
|
# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do
|
|
|
|
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
|
|
|
|
if (LIBCXX_BUILT_STANDALONE)
|
|
|
|
# NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
|
|
|
|
# But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
|
|
|
|
if (LLVM_USE_SANITIZER AND NOT MSVC)
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG
|
2014-11-14 21:38:07 +01:00
|
|
|
"-fno-omit-frame-pointer")
|
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
|
|
|
|
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
|
2014-11-15 07:26:30 +01:00
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG
|
2014-11-14 21:38:07 +01:00
|
|
|
"-gline-tables-only")
|
|
|
|
endif()
|
2014-08-18 07:03:46 +02:00
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "Address")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=address")
|
2014-08-18 07:03:46 +02:00
|
|
|
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=memory")
|
2014-08-18 07:03:46 +02:00
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize-memory-track-origins")
|
2014-08-18 07:03:46 +02:00
|
|
|
endif()
|
2014-10-17 01:21:59 +02:00
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
|
2014-11-15 07:26:30 +01:00
|
|
|
list(APPEND LIBCXX_CXX_FLAGS
|
2014-10-17 01:21:59 +02:00
|
|
|
"-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover")
|
2014-11-18 22:26:45 +01:00
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
|
|
|
|
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=thread")
|
2014-08-18 07:03:46 +02:00
|
|
|
else()
|
|
|
|
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
|
|
|
|
endif()
|
|
|
|
elseif(MSVC)
|
|
|
|
message(WARNING "LLVM_USE_SANITIZER is not supported with MSVC")
|
|
|
|
endif()
|
2013-10-21 17:56:35 +02:00
|
|
|
endif()
|
|
|
|
|
2015-01-16 03:27:17 +01:00
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_TARGET_TRIPLE
|
|
|
|
"-target ${LIBCXX_TARGET_TRIPLE}")
|
2015-03-31 06:15:45 +02:00
|
|
|
|
2015-01-16 01:55:15 +01:00
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
|
|
|
|
append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN
|
|
|
|
"-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
|
|
|
|
|
2015-03-31 06:15:45 +02:00
|
|
|
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
|
|
|
|
message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
|
|
|
|
endif()
|
|
|
|
|
2014-11-15 07:26:30 +01:00
|
|
|
string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}")
|
2010-12-10 20:47:54 +01:00
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Source Code
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
include_directories(include)
|
2013-11-15 18:18:57 +01:00
|
|
|
add_subdirectory(include)
|
2010-12-10 20:47:54 +01:00
|
|
|
|
|
|
|
# Add source code. This also contains all of the logic for deciding linker flags
|
|
|
|
# soname, etc...
|
|
|
|
add_subdirectory(lib)
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Tests
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
add_subdirectory(test)
|