2010-12-11 03:47:54 +08:00
|
|
|
# See www/CMake.html for instructions on how to build libcxx with CMake.
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Project
|
|
|
|
#===============================================================================
|
2016-06-01 04:21:52 +08:00
|
|
|
cmake_minimum_required(VERSION 3.4.3)
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-01-27 05:56:45 +08:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
if(POLICY CMP0022)
|
|
|
|
cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
|
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
2015-12-30 11:39:03 +08:00
|
|
|
${CMAKE_MODULE_PATH}
|
2010-12-11 03:47:54 +08:00
|
|
|
)
|
|
|
|
|
2015-12-30 11:39:03 +08:00
|
|
|
# Find the LLVM sources and simulate LLVM CMake options.
|
|
|
|
include(HandleOutOfTreeLLVM)
|
2016-02-08 11:50:18 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD)
|
2016-02-08 11:50:18 +08:00
|
|
|
project(libcxx CXX C)
|
|
|
|
|
|
|
|
set(PACKAGE_NAME libcxx)
|
2016-08-09 02:01:50 +08:00
|
|
|
set(PACKAGE_VERSION 4.0.0svn)
|
2016-02-08 11:50:18 +08:00
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
|
|
|
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
2016-02-08 11:50:18 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD AND NOT LLVM_FOUND)
|
2015-12-30 11:39:03 +08:00
|
|
|
message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
|
|
|
|
"llvm-config not found and LLVM_PATH not defined.\n"
|
|
|
|
"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
|
|
|
|
"or -DLLVM_PATH=path/to/llvm-source-root.")
|
|
|
|
endif()
|
|
|
|
|
2016-02-08 11:50:18 +08: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."
|
|
|
|
)
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Basic options ---------------------------------------------------------------
|
2015-07-30 07:46:55 +08:00
|
|
|
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
|
|
|
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
|
2016-08-09 06:57:25 +08:00
|
|
|
option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
|
2016-05-04 05:30:18 +08:00
|
|
|
option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
|
2016-06-18 03:46:40 +08:00
|
|
|
option(LIBCXX_ENABLE_FILESYSTEM
|
|
|
|
"Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
|
[libcxx] Add support for benchmark tests using Google Benchmark.
Summary:
This patch does the following:
1. Checks in a copy of the Google Benchmark library into the libc++ repo under `utils/google-benchmark`.
2. Teaches libc++ how to build Google Benchmark against both (A) in-tree libc++ and (B) the platforms native STL.
3. Allows performance benchmarks to be built as part of the libc++ build.
Building the benchmarks (and Google Benchmark) is off by default. It must be enabled using the CMake option `-DLIBCXX_INCLUDE_BENCHMARKS=ON`. When this option is enabled the tests under `libcxx/benchmarks` can be built using the `libcxx-benchmarks` target.
On Linux platforms where libstdc++ is the default STL the CMake option `-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON` can be used to build each benchmark test against libstdc++ as well. This is useful for comparing performance between standard libraries.
Support for benchmarks is currently very minimal. They must be manually run by the user and there is no mechanism for detecting performance regressions.
Known Issues:
* `-DLIBCXX_INCLUDE_BENCHMARKS=ON` is only supported for Clang, and not GCC, since the `-stdlib=libc++` option is needed to build Google Benchmark.
Reviewers: danalbert, dberlin, chandlerc, mclow.lists, jroelofs
Subscribers: chandlerc, dberlin, tberghammer, danalbert, srhines, hfinkel
Differential Revision: https://reviews.llvm.org/D22240
llvm-svn: 276049
2016-07-20 07:07:03 +08:00
|
|
|
option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" OFF)
|
|
|
|
option(LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB "Build the benchmarks against the native STL" OFF)
|
2015-08-23 03:40:49 +08:00
|
|
|
option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
|
|
|
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
|
2015-08-27 04:18:21 +08:00
|
|
|
option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
|
2016-05-04 05:30:18 +08:00
|
|
|
option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF)
|
2015-10-14 07:48:28 +08:00
|
|
|
set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
|
|
|
|
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2016-08-09 06:57:25 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "libc++ must be built as either a shared or static library.")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# ABI Library options ---------------------------------------------------------
|
|
|
|
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
|
|
|
|
"Specify C++ ABI library to use." FORCE)
|
|
|
|
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
|
|
|
|
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
|
|
|
|
|
2015-10-23 04:54:27 +08:00
|
|
|
# Setup the default options if LIBCXX_CXX_ABI is not specified.
|
|
|
|
if (NOT LIBCXX_CXX_ABI)
|
2016-08-19 05:31:51 +08:00
|
|
|
if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND
|
2015-10-23 04:54:27 +08:00
|
|
|
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
|
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
|
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
|
|
|
|
set(LIBCXX_CXX_ABI_INTREE 1)
|
2016-08-09 02:01:50 +08:00
|
|
|
else()
|
2015-10-23 04:54:27 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
|
|
|
else()
|
2015-10-23 04:54:27 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
|
2016-08-09 02:01:50 +08:00
|
|
|
endif()
|
2015-10-23 04:54:27 +08:00
|
|
|
|
2015-10-16 06:41:51 +08:00
|
|
|
# Use a static copy of the ABI library when linking libc++. This option
|
|
|
|
# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
# Generate and install a linker script inplace of libc++.so. The linker script
|
2015-10-16 06:41:51 +08:00
|
|
|
# will link libc++ to the correct ABI library. This option is on by default
|
|
|
|
# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
|
2015-10-23 04:50:07 +08:00
|
|
|
# is on. This option is also disabled when the ABI library is not specified
|
|
|
|
# or is specified to be "none".
|
2015-10-16 06:41:51 +08:00
|
|
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
|
2015-10-16 07:04:54 +08:00
|
|
|
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
|
2015-10-23 04:54:27 +08:00
|
|
|
AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
|
2016-05-15 07:58:11 +08:00
|
|
|
AND PYTHONINTERP_FOUND
|
|
|
|
AND LIBCXX_ENABLE_SHARED)
|
2015-10-16 06:41:51 +08:00
|
|
|
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
|
|
|
|
endif()
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
|
2015-10-16 06:41:51 +08:00
|
|
|
"Use and install a linker script for the given ABI library"
|
2015-10-16 07:04:54 +08:00
|
|
|
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
|
2015-10-15 03:54:03 +08:00
|
|
|
|
2015-07-31 06:30:34 +08: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)
|
|
|
|
|
|
|
|
# Target options --------------------------------------------------------------
|
|
|
|
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
|
|
|
|
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
|
|
|
|
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
|
|
|
|
|
|
|
|
# Feature options -------------------------------------------------------------
|
|
|
|
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
|
|
|
|
option(LIBCXX_ENABLE_RTTI "Use run time type information." 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!)
llvm-svn: 232049
2015-03-12 23:44:39 +08:00
|
|
|
option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
|
2015-03-26 22:35:46 +08: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-07 05:02:58 +08:00
|
|
|
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
|
2015-06-24 16:44:38 +08:00
|
|
|
option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
|
2014-12-07 05:02:58 +08:00
|
|
|
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
|
|
|
|
"Build libc++ with support for a monotonic clock.
|
2015-08-25 05:20:07 +08:00
|
|
|
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
|
2015-11-09 18:21:04 +08:00
|
|
|
option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
|
2016-05-26 01:40:09 +08:00
|
|
|
option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# Misc options ----------------------------------------------------------------
|
2015-10-10 11:34:52 +08:00
|
|
|
# FIXME: Turn -pedantic back ON. It is currently off because it warns
|
|
|
|
# about #include_next which is used everywhere.
|
|
|
|
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
2016-07-12 22:39:13 +08:00
|
|
|
option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2015-03-31 12:15:45 +08:00
|
|
|
option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
|
|
|
|
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
|
2015-07-31 06:30:34 +08:00
|
|
|
"The Profile-rt library used to build with code coverage")
|
|
|
|
|
2015-08-27 04:18:21 +08:00
|
|
|
# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
|
|
|
|
# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
|
|
|
|
# will not be generated and a warning will be issued.
|
|
|
|
option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
|
|
|
|
mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
|
|
|
|
if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
|
|
|
|
message(WARNING "Disabling libc++ install rules because installation would "
|
|
|
|
"overwrite the systems installation. Configure with "
|
|
|
|
"-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
|
|
|
|
mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
|
|
|
|
set(LIBCXX_INSTALL_HEADERS OFF)
|
|
|
|
set(LIBCXX_INSTALL_LIBRARY OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-12-17 07:41:05 +08:00
|
|
|
set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF)
|
|
|
|
if (XCODE OR MSVC_IDE)
|
|
|
|
set(LIBCXX_CONFIGURE_IDE_DEFAULT ON)
|
|
|
|
endif()
|
|
|
|
option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE"
|
|
|
|
${LIBCXX_CONFIGURE_IDE_DEFAULT})
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Check option configurations
|
|
|
|
#===============================================================================
|
|
|
|
|
2016-06-18 03:46:40 +08:00
|
|
|
if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
|
|
|
|
# LIBCXX_ENABLE_THREADS is on.
|
|
|
|
if(LIBCXX_ENABLE_THREADS AND 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.")
|
2015-07-30 05:07:28 +08:00
|
|
|
endif()
|
|
|
|
|
2016-05-26 01:40:09 +08:00
|
|
|
if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
|
|
|
|
" when LIBCXX_ENABLE_THREADS is also set to ON.")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
|
|
|
|
# is ON.
|
|
|
|
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
|
|
|
|
message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS)
|
|
|
|
# and check that we can build with 32 bits if requested.
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
|
|
|
|
if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
|
|
|
|
message(STATUS "Building 32 bits executables and libraries.")
|
|
|
|
endif()
|
|
|
|
elseif(LIBCXX_BUILD_32_BITS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Check that this option is not enabled on Apple and emit a usage warning.
|
2015-03-03 23:59:51 +08: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()
|
|
|
|
|
2015-10-15 03:54:03 +08:00
|
|
|
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
if (APPLE)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
|
|
|
|
endif()
|
|
|
|
if (NOT PYTHONINTERP_FOUND)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.")
|
|
|
|
endif()
|
2016-05-15 07:58:11 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.")
|
|
|
|
endif()
|
2015-10-15 03:54:03 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
message(FATAL_ERROR "Conflicting options given.
|
|
|
|
LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
|
|
|
|
LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
|
|
|
|
endif()
|
|
|
|
|
2015-11-09 18:21:04 +08:00
|
|
|
if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
|
|
|
|
message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off"
|
|
|
|
"when building for Musl with LIBCXX_HAS_MUSL_LIBC.")
|
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
2014-12-20 11:16:55 +08: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 20:15:47 +08:00
|
|
|
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
|
2014-12-20 11:16:55 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
|
|
|
|
2014-11-15 14:26:30 +08: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_COMPILE_FLAGS "")
|
|
|
|
set(LIBCXX_LINK_FLAGS "")
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_LIBRARIES "")
|
2014-11-15 14:26:30 +08:00
|
|
|
|
2016-06-02 09:10:08 +08:00
|
|
|
# Include macros for adding and removing libc++ flags.
|
|
|
|
include(HandleLibcxxFlags)
|
|
|
|
|
|
|
|
# Target flags ================================================================
|
|
|
|
# These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that
|
|
|
|
# 'config-ix' use them during feature checks. It also adds them to both
|
|
|
|
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
|
|
|
|
add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
|
|
|
|
add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
|
|
|
|
add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
|
|
|
|
add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
|
|
|
|
|
2014-11-16 01:25:23 +08:00
|
|
|
# Configure compiler.
|
|
|
|
include(config-ix)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2015-03-31 12:15:45 +08:00
|
|
|
# Configure coverage options.
|
|
|
|
if (LIBCXX_GENERATE_COVERAGE)
|
|
|
|
include(CodeCoverage)
|
|
|
|
set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
|
|
|
|
endif()
|
2014-11-16 01:25:23 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
|
|
|
2014-11-16 01:25:23 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
|
|
|
|
2016-03-05 22:22:02 +08:00
|
|
|
include(HandleLibCXXABI) # Setup the ABI library flags
|
2015-07-29 08:03:51 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Remove flags that may have snuck in.
|
|
|
|
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
|
|
|
|
-stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
|
|
|
|
|
2015-10-14 07:56:33 +08:00
|
|
|
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
|
2015-10-16 04:27:15 +08:00
|
|
|
# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
|
|
|
|
# so they don't get transformed into -Wno and -errors respectivly.
|
|
|
|
remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
|
2015-10-14 07:56:33 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Required flags ==============================================================
|
2016-08-15 06:51:54 +08:00
|
|
|
set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
|
|
|
|
add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})
|
|
|
|
mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME)
|
|
|
|
if (NOT MSVC AND NOT ${SUPPORTS_DIALECT_NAME})
|
|
|
|
message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}")
|
2013-10-05 08:07:35 +08:00
|
|
|
endif()
|
2013-10-21 23:56:35 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# On all systems the system c++ standard library headers need to be excluded.
|
|
|
|
# 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
|
|
|
|
add_compile_flags_if_supported(-nostdinc++)
|
|
|
|
|
|
|
|
# Warning flags ===============================================================
|
|
|
|
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
|
|
add_compile_flags_if_supported(
|
|
|
|
-Wall -W -Wwrite-strings
|
2016-06-18 03:46:40 +08:00
|
|
|
-Wno-unused-parameter -Wno-long-long -Wno-user-defined-literals
|
2016-06-19 02:55:18 +08:00
|
|
|
-Wno-covered-switch-default
|
2015-07-31 06:30:34 +08:00
|
|
|
-Werror=return-type)
|
2010-12-11 03:47:54 +08:00
|
|
|
if (LIBCXX_ENABLE_WERROR)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-Werror)
|
|
|
|
add_compile_flags_if_supported(-WX)
|
2015-07-31 09:25:01 +08:00
|
|
|
else()
|
|
|
|
# TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
|
|
|
|
# added elsewhere.
|
|
|
|
add_compile_flags_if_supported(-Wno-error)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
|
|
|
if (LIBCXX_ENABLE_PEDANTIC)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-pedantic)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2016-07-12 22:39:13 +08:00
|
|
|
if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
|
|
|
|
add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
|
|
|
|
endif()
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Exception flags =============================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
if (LIBCXX_ENABLE_EXCEPTIONS)
|
|
|
|
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
|
|
# functions never throw a C++ exception.
|
2015-07-31 06:30:34 +08:00
|
|
|
add_compile_flags_if_supported(-EHsc)
|
2010-12-11 03:47:54 +08:00
|
|
|
else()
|
2015-07-31 06:30:34 +08:00
|
|
|
add_definitions(-D_LIBCPP_NO_EXCEPTIONS)
|
|
|
|
add_compile_flags_if_supported(-EHs- -EHa-)
|
|
|
|
add_compile_flags_if_supported(-fno-exceptions)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# RTTI flags ==================================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_definitions(-D_LIBCPP_NO_RTTI)
|
|
|
|
add_compile_flags_if_supported(-GR-)
|
|
|
|
add_compile_flags_if_supported(-fno-rtti)
|
2010-12-11 03:47:54 +08:00
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# Assertion flags =============================================================
|
|
|
|
define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
|
|
|
|
define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
|
2012-08-06 01:37:39 +08:00
|
|
|
if (LIBCXX_ENABLE_ASSERTIONS)
|
2010-12-11 03:47:54 +08:00
|
|
|
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
2015-07-31 06:30:34 +08:00
|
|
|
define_if_not(MSVC -D_DEBUG)
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
# Feature flags ===============================================================
|
|
|
|
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
|
2015-07-30 07:46:55 +08:00
|
|
|
|
2015-08-25 05:20:07 +08:00
|
|
|
# Sanitizer flags =============================================================
|
2010-12-11 03:47:54 +08:00
|
|
|
|
2016-08-19 05:31:51 +08:00
|
|
|
# Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do
|
2015-07-30 07:46:55 +08:00
|
|
|
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
|
2016-08-19 05:31:51 +08:00
|
|
|
if (LIBCXX_STANDALONE_BUILD)
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LLVM_USE_SANITIZER "" CACHE STRING
|
|
|
|
"Define the sanitizer used to build the library and tests")
|
2015-07-30 07:46:55 +08:00
|
|
|
# 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)
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags_if_supported("-fno-omit-frame-pointer")
|
|
|
|
add_flags_if_supported("-gline-tables-only")
|
|
|
|
|
2015-07-30 07:46:55 +08:00
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
|
|
|
|
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags_if_supported("-gline-tables-only")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "Address")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize=address")
|
2015-07-30 07:46:55 +08:00
|
|
|
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags(-fsanitize=memory)
|
2015-07-30 07:46:55 +08:00
|
|
|
if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize-memory-track-origins")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
|
2015-07-30 07:46:55 +08:00
|
|
|
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
|
2015-07-31 06:30:34 +08:00
|
|
|
add_flags(-fsanitize=thread)
|
2015-07-30 07:46:55 +08:00
|
|
|
else()
|
|
|
|
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
elseif(LLVM_USE_SANITIZER AND MSVC)
|
|
|
|
message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
|
2015-07-30 07:46:55 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
|
|
|
|
# Configuration file flags =====================================================
|
2015-10-14 07:48:28 +08:00
|
|
|
if (NOT LIBCXX_ABI_VERSION EQUAL "1")
|
|
|
|
config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
|
|
|
|
endif()
|
|
|
|
config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
|
|
|
|
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
|
|
|
|
config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
|
|
|
|
|
2016-05-26 01:40:09 +08:00
|
|
|
config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
|
2015-11-09 18:21:04 +08:00
|
|
|
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
|
|
|
|
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
if (LIBCXX_NEEDS_SITE_CONFIG)
|
|
|
|
configure_file(
|
|
|
|
include/__config_site.in
|
|
|
|
${LIBCXX_BINARY_DIR}/__config_site
|
|
|
|
@ONLY)
|
2015-10-14 08:22:05 +08:00
|
|
|
# Provide the config definitions by included the generated __config_site
|
|
|
|
# file at compile time.
|
|
|
|
add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
|
[libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,
This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.
Please read the design documentation added in this patch for a description of how it works.
Reviewers: mclow.lists, danalbert, jroelofs, EricWF
Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits
Differential Revision: http://reviews.llvm.org/D13407
llvm-svn: 250235
2015-10-14 06:12:02 +08:00
|
|
|
endif()
|
|
|
|
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
2015-07-31 06:30:34 +08:00
|
|
|
# Setup Source Code And Tests
|
2010-12-11 03:47:54 +08:00
|
|
|
#===============================================================================
|
|
|
|
include_directories(include)
|
2013-11-16 01:18:57 +08:00
|
|
|
add_subdirectory(include)
|
2010-12-11 03:47:54 +08:00
|
|
|
add_subdirectory(lib)
|
2015-08-23 03:40:49 +08:00
|
|
|
|
[libcxx] Add support for benchmark tests using Google Benchmark.
Summary:
This patch does the following:
1. Checks in a copy of the Google Benchmark library into the libc++ repo under `utils/google-benchmark`.
2. Teaches libc++ how to build Google Benchmark against both (A) in-tree libc++ and (B) the platforms native STL.
3. Allows performance benchmarks to be built as part of the libc++ build.
Building the benchmarks (and Google Benchmark) is off by default. It must be enabled using the CMake option `-DLIBCXX_INCLUDE_BENCHMARKS=ON`. When this option is enabled the tests under `libcxx/benchmarks` can be built using the `libcxx-benchmarks` target.
On Linux platforms where libstdc++ is the default STL the CMake option `-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON` can be used to build each benchmark test against libstdc++ as well. This is useful for comparing performance between standard libraries.
Support for benchmarks is currently very minimal. They must be manually run by the user and there is no mechanism for detecting performance regressions.
Known Issues:
* `-DLIBCXX_INCLUDE_BENCHMARKS=ON` is only supported for Clang, and not GCC, since the `-stdlib=libc++` option is needed to build Google Benchmark.
Reviewers: danalbert, dberlin, chandlerc, mclow.lists, jroelofs
Subscribers: chandlerc, dberlin, tberghammer, danalbert, srhines, hfinkel
Differential Revision: https://reviews.llvm.org/D22240
llvm-svn: 276049
2016-07-20 07:07:03 +08:00
|
|
|
if (LIBCXX_INCLUDE_BENCHMARKS)
|
|
|
|
add_subdirectory(benchmarks)
|
|
|
|
endif()
|
2015-07-31 06:30:34 +08:00
|
|
|
if (LIBCXX_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2015-08-23 03:40:49 +08:00
|
|
|
if (LIBCXX_INCLUDE_DOCS)
|
|
|
|
add_subdirectory(docs)
|
|
|
|
endif()
|