1037e7968Spatrick# See https://libcxx.llvm.org/docs/BuildingLibcxx.html for instructions on how 2037e7968Spatrick# to build libcxx with CMake. 3037e7968Spatrick 446035553Spatrick#=============================================================================== 546035553Spatrick# Setup Project 646035553Spatrick#=============================================================================== 776d0caaeSpatrickcmake_minimum_required(VERSION 3.13.4) 846035553Spatrick 9*4bdff4beSrobertset(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") 10*4bdff4beSrobert 1146035553Spatrick# Add path for custom modules 12*4bdff4beSrobertlist(INSERT CMAKE_MODULE_PATH 0 1346035553Spatrick "${CMAKE_CURRENT_SOURCE_DIR}/cmake" 1446035553Spatrick "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" 15*4bdff4beSrobert "${LLVM_COMMON_CMAKE_UTILS}" 16*4bdff4beSrobert "${LLVM_COMMON_CMAKE_UTILS}/Modules" 1746035553Spatrick ) 1846035553Spatrick 1976d0caaeSpatrickset(CMAKE_FOLDER "libc++") 2076d0caaeSpatrick 2176d0caaeSpatrickset(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 2276d0caaeSpatrickset(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) 2376d0caaeSpatrickset(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") 2476d0caaeSpatrick 25*4bdff4beSrobertinclude(GNUInstallDirs) 2646035553Spatrick 2746035553Spatrick# Require out of source build. 2846035553Spatrickinclude(MacroEnsureOutOfSourceBuild) 2946035553SpatrickMACRO_ENSURE_OUT_OF_SOURCE_BUILD( 3046035553Spatrick "${PROJECT_NAME} requires an out of source build. Please create a separate 3146035553Spatrick build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." 3246035553Spatrick ) 3346035553Spatrickif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") 3446035553Spatrick message(STATUS "Configuring for clang-cl") 3546035553Spatrick set(LIBCXX_TARGETING_CLANG_CL ON) 3646035553Spatrickendif() 3746035553Spatrick 3846035553Spatrickif (MSVC) 3946035553Spatrick set(LIBCXX_TARGETING_MSVC ON) 4046035553Spatrick message(STATUS "Configuring for MSVC") 4146035553Spatrickelse() 4246035553Spatrick set(LIBCXX_TARGETING_MSVC OFF) 4346035553Spatrickendif() 4446035553Spatrick 4546035553Spatrick#=============================================================================== 4646035553Spatrick# Setup CMake Options 4746035553Spatrick#=============================================================================== 4846035553Spatrickinclude(CMakeDependentOption) 4946035553Spatrickinclude(HandleCompilerRT) 5046035553Spatrick 5146035553Spatrick# Basic options --------------------------------------------------------------- 52*4bdff4beSrobertoption(LIBCXX_ENABLE_ASSERTIONS 53*4bdff4beSrobert "Enable assertions inside the compiled library, and at the same time make it the 54*4bdff4beSrobert default when compiling user code. Note that assertions can be enabled or disabled 55*4bdff4beSrobert by users in their own code regardless of this option." OFF) 5646035553Spatrickoption(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) 5746035553Spatrickoption(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) 5846035553Spatrickset(ENABLE_FILESYSTEM_DEFAULT ON) 5976d0caaeSpatrickif (WIN32 AND NOT MINGW) 6076d0caaeSpatrick # Filesystem is buildable for windows, but it requires __int128 helper 6176d0caaeSpatrick # functions, that currently are provided by libgcc or compiler_rt builtins. 6276d0caaeSpatrick # These are available in MinGW environments, but not currently in MSVC 6376d0caaeSpatrick # environments. 6446035553Spatrick set(ENABLE_FILESYSTEM_DEFAULT OFF) 6546035553Spatrickendif() 6646035553Spatrickoption(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library" 6746035553Spatrick ${ENABLE_FILESYSTEM_DEFAULT}) 6846035553Spatrickoption(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) 6946035553Spatrickoption(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) 70*4bdff4beSrobertoption(LIBCXX_ENABLE_DEBUG_MODE 71*4bdff4beSrobert "Whether to build libc++ with the debug mode enabled. 72*4bdff4beSrobert By default, this is turned off. Turning it on results in a different ABI (additional 73*4bdff4beSrobert symbols but also potentially different layouts of types), and one should not mix code 74*4bdff4beSrobert built against a dylib that has debug mode and code built against a regular dylib." OFF) 7576d0caaeSpatrickoption(LIBCXX_ENABLE_RANDOM_DEVICE 7676d0caaeSpatrick "Whether to include support for std::random_device in the library. Disabling 7776d0caaeSpatrick this can be useful when building the library for platforms that don't have 7876d0caaeSpatrick a source of randomness, such as some embedded platforms. When this is not 7976d0caaeSpatrick supported, most of <random> will still be available, but std::random_device 8076d0caaeSpatrick will not." ON) 8176d0caaeSpatrickoption(LIBCXX_ENABLE_LOCALIZATION 8276d0caaeSpatrick "Whether to include support for localization in the library. Disabling 8376d0caaeSpatrick localization can be useful when porting to platforms that don't support 8476d0caaeSpatrick the C locale API (e.g. embedded). When localization is not supported, 8576d0caaeSpatrick several parts of the library will be disabled: <iostream>, <regex>, <locale> 8676d0caaeSpatrick will be completely unusable, and other parts may be only partly available." ON) 87*4bdff4beSrobertoption(LIBCXX_ENABLE_FSTREAM 88*4bdff4beSrobert "Whether to include support for <fstream>." ON) # TODO: Consider rolling that into LIBCXX_ENABLE_FILESYSTEM 89*4bdff4beSrobertoption(LIBCXX_ENABLE_UNICODE 90*4bdff4beSrobert "Whether to include support for Unicode in the library. Disabling Unicode can 91*4bdff4beSrobert be useful when porting to platforms that don't support UTF-8 encoding (e.g. 92*4bdff4beSrobert embedded)." ON) 93*4bdff4beSrobertoption(LIBCXX_ENABLE_WIDE_CHARACTERS 94*4bdff4beSrobert "Whether to include support for wide characters in the library. Disabling 95*4bdff4beSrobert wide character support can be useful when porting to platforms that don't 96*4bdff4beSrobert support the C functionality for wide characters. When wide characters are 97*4bdff4beSrobert not supported, several parts of the library will be disabled, notably the 98*4bdff4beSrobert wide character specializations of std::basic_string." ON) 9976d0caaeSpatrickoption(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS 10076d0caaeSpatrick "Whether to turn on vendor availability annotations on declarations that depend 10176d0caaeSpatrick on definitions in a shared library. By default, we assume that we're not building 10276d0caaeSpatrick libc++ for any specific vendor, and we disable those annotations. Vendors wishing 10376d0caaeSpatrick to provide compile-time errors when using features unavailable on some version of 10476d0caaeSpatrick the shared library they shipped should turn this on and see `include/__availability` 10576d0caaeSpatrick for more details." OFF) 106*4bdff4beSrobertoption(LIBCXX_ENABLE_CLANG_TIDY "Whether to compile and run clang-tidy checks" OFF) 107*4bdff4beSrobert 108*4bdff4beSrobertif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 109*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-gcc.cfg.in") 110*4bdff4beSrobertelseif(MINGW) 111*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-mingw.cfg.in") 112*4bdff4beSrobertelseif(WIN32) # clang-cl 113*4bdff4beSrobert if (LIBCXX_ENABLE_SHARED) 114*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared-clangcl.cfg.in") 115*4bdff4beSrobert else() 116*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static-clangcl.cfg.in") 117*4bdff4beSrobert endif() 118*4bdff4beSrobertelse() 119*4bdff4beSrobert if (LIBCXX_ENABLE_SHARED) 120*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-shared.cfg.in") 121*4bdff4beSrobert else() 122*4bdff4beSrobert set(LIBCXX_DEFAULT_TEST_CONFIG "llvm-libc++-static.cfg.in") 123*4bdff4beSrobert endif() 124*4bdff4beSrobertendif() 125*4bdff4beSrobertset(LIBCXX_TEST_CONFIG "${LIBCXX_DEFAULT_TEST_CONFIG}" CACHE STRING 126*4bdff4beSrobert "The path to the Lit testing configuration to use when running the tests. 127*4bdff4beSrobert If a relative path is provided, it is assumed to be relative to '<monorepo>/libcxx/test/configs'.") 128*4bdff4beSrobertif (NOT IS_ABSOLUTE "${LIBCXX_TEST_CONFIG}") 129*4bdff4beSrobert set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXX_TEST_CONFIG}") 130*4bdff4beSrobertendif() 131*4bdff4beSrobertmessage(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") 132037e7968Spatrickset(LIBCXX_TEST_PARAMS "" CACHE STRING 133037e7968Spatrick "A list of parameters to run the Lit test suite with.") 13446035553Spatrick 13546035553Spatrick# Benchmark options ----------------------------------------------------------- 13646035553Spatrickoption(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) 13746035553Spatrick 13846035553Spatrickset(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) 13946035553Spatrickset(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING 14046035553Spatrick "Arguments to pass when running the benchmarks using check-cxx-benchmarks") 14146035553Spatrick 14246035553Spatrickset(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING 14346035553Spatrick "Build the benchmarks against the specified native STL. 14446035553Spatrick The value must be one of libc++/libstdc++") 14546035553Spatrickset(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING 14646035553Spatrick "Use alternate GCC toolchain when building the native benchmarks") 14746035553Spatrick 14846035553Spatrickif (LIBCXX_BENCHMARK_NATIVE_STDLIB) 14946035553Spatrick if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" 15046035553Spatrick OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) 15146035553Spatrick message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " 15246035553Spatrick "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") 15346035553Spatrick endif() 15446035553Spatrickendif() 15546035553Spatrick 15646035553Spatrickoption(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) 15746035553Spatrickset(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING 15846035553Spatrick "Define suffix of library directory name (32/64)") 15946035553Spatrickoption(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) 16046035553Spatrickoption(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) 16146035553Spatrickcmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY 16246035553Spatrick "Install the static libc++ library." ON 16346035553Spatrick "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF) 16446035553Spatrickcmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY 16546035553Spatrick "Install the shared libc++ library." ON 16646035553Spatrick "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) 16746035553Spatrick 168*4bdff4beSrobertoption(LIBCXX_ABI_UNSTABLE "Use the unstable ABI of libc++. This is equivalent to specifying LIBCXX_ABI_VERSION=n, where n is the not-yet-stable version." OFF) 169*4bdff4beSrobertif (LIBCXX_ABI_UNSTABLE) 170*4bdff4beSrobert set(abi_version "2") 171*4bdff4beSrobertelse() 172*4bdff4beSrobert set(abi_version "1") 173*4bdff4beSrobertendif() 174*4bdff4beSrobertset(LIBCXX_ABI_VERSION "${abi_version}" CACHE STRING 175*4bdff4beSrobert "ABI version of libc++. Can be either 1 or 2, where 2 is currently the unstable ABI. 176*4bdff4beSrobert Defaults to 1 unless LIBCXX_ABI_UNSTABLE is specified, in which case this is 2.") 177*4bdff4beSrobertset(LIBCXX_LIBRARY_VERSION "${LIBCXX_ABI_VERSION}.0" CACHE STRING 178*4bdff4beSrobert "Version of libc++. This will be reflected in the name of the shared library produced. 179*4bdff4beSrobert For example, -DLIBCXX_LIBRARY_VERSION=x.y will result in the library being named 180*4bdff4beSrobert libc++.x.y.dylib, along with the usual symlinks pointing to that. On Apple platforms, 181*4bdff4beSrobert this also controls the linker's 'current_version' property.") 182*4bdff4beSrobertset(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") 183*4bdff4beSrobertif (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*") 184*4bdff4beSrobert message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier, got '${LIBCXX_ABI_NAMESPACE}'.") 185*4bdff4beSrobertendif() 18646035553Spatrickoption(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.") 18746035553Spatrickoption(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.") 18846035553Spatrick 18976d0caaeSpatrickset(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "default" CACHE STRING 19076d0caaeSpatrick "Override the implementation to use for comparing typeinfos. By default, this 19176d0caaeSpatrick is detected automatically by the library, but this option allows overriding 19276d0caaeSpatrick which implementation is used unconditionally. 19346035553Spatrick 19476d0caaeSpatrick See the documentation in <libcxx/include/typeinfo> for details on what each 19576d0caaeSpatrick value means.") 19676d0caaeSpatrickset(TYPEINFO_COMPARISON_VALUES "default;1;2;3") 19776d0caaeSpatrickif (NOT ("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" IN_LIST TYPEINFO_COMPARISON_VALUES)) 198037e7968Spatrick message(FATAL_ERROR "Value '${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}' is not a valid value for 199037e7968Spatrick LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION") 20046035553Spatrickendif() 20146035553Spatrick 20246035553Spatrickset(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.") 203*4bdff4beSrobertoption(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site") 20446035553Spatrickoption(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) 205*4bdff4beSrobert 206*4bdff4beSrobertoption(LIBCXX_ENABLE_BACKWARDS_COMPATIBILITY_DEBUG_MODE_SYMBOLS 207*4bdff4beSrobert "Whether to include the old Debug mode symbols in the compiled library. This 208*4bdff4beSrobert is provided for backwards compatibility since the compiled library used to 209*4bdff4beSrobert always contain those symbols, regardless of whether the library was built 210*4bdff4beSrobert with the debug mode enabled. This is OFF by default, please contact the libc++ 211*4bdff4beSrobert developers if you need to turn this on, as this will be removed in LLVM 16." OFF) 21246035553Spatrick 21346035553Spatrick# ABI Library options --------------------------------------------------------- 21446035553Spatrickif (LIBCXX_TARGETING_MSVC) 215*4bdff4beSrobert set(LIBCXX_DEFAULT_ABI_LIBRARY "vcruntime") 21646035553Spatrickelseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") 217*4bdff4beSrobert set(LIBCXX_DEFAULT_ABI_LIBRARY "libcxxrt") 21846035553Spatrickelse() 219*4bdff4beSrobert set(LIBCXX_DEFAULT_ABI_LIBRARY "libcxxabi") 22046035553Spatrickendif() 221*4bdff4beSrobert 222*4bdff4beSrobertset(LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system-libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) 223*4bdff4beSrobertset(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING "Specify C++ ABI library to use. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") 224*4bdff4beSrobertif (NOT "${LIBCXX_CXX_ABI}" IN_LIST LIBCXX_SUPPORTED_ABI_LIBRARIES) 225*4bdff4beSrobert message(FATAL_ERROR "Unsupported C++ ABI library: '${LIBCXX_CXX_ABI}'. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") 22646035553Spatrickendif() 22746035553Spatrick 22846035553Spatrickoption(LIBCXX_ENABLE_STATIC_ABI_LIBRARY 22946035553Spatrick "Use a static copy of the ABI library when linking libc++. 23046035553Spatrick This option cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT." OFF) 23146035553Spatrick 232*4bdff4beSrobertoption(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY 233*4bdff4beSrobert "Statically link the ABI library to static library" 234*4bdff4beSrobert ${LIBCXX_ENABLE_STATIC_ABI_LIBRARY}) 23546035553Spatrick 236*4bdff4beSrobertoption(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY 237*4bdff4beSrobert "Statically link the ABI library to shared library" 238*4bdff4beSrobert ${LIBCXX_ENABLE_STATIC_ABI_LIBRARY}) 23946035553Spatrick 24046035553Spatrick# Generate and install a linker script inplace of libc++.so. The linker script 24146035553Spatrick# will link libc++ to the correct ABI library. This option is on by default 242*4bdff4beSrobert# on UNIX platforms other than Apple unless 243*4bdff4beSrobert# 'LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY' is on. This option is also 244*4bdff4beSrobert# disabled when the ABI library is not specified or is specified to be "none". 24546035553Spatrickset(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) 24646035553Spatrickif (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY 247*4bdff4beSrobert AND NOT LIBCXX_CXX_ABI STREQUAL "none" 248037e7968Spatrick AND Python3_EXECUTABLE 24946035553Spatrick AND LIBCXX_ENABLE_SHARED) 25046035553Spatrick set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) 25146035553Spatrickendif() 25246035553Spatrick 25346035553Spatrickoption(LIBCXX_ENABLE_ABI_LINKER_SCRIPT 25446035553Spatrick "Use and install a linker script for the given ABI library" 25546035553Spatrick ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) 25646035553Spatrick 25746035553Spatrickoption(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS 25876d0caaeSpatrick "Build libc++ with definitions for operator new/delete. These are normally 25976d0caaeSpatrick defined in libc++abi, but this option can be used to define them in libc++ 26076d0caaeSpatrick instead. If you define them in libc++, make sure they are NOT defined in 26176d0caaeSpatrick libc++abi. Doing otherwise is an ODR violation." OFF) 26246035553Spatrick# Build libc++abi with libunwind. We need this option to determine whether to 26346035553Spatrick# link with libunwind or libgcc_s while running the test cases. 26446035553Spatrickoption(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) 26546035553Spatrick 26646035553Spatrick# Target options -------------------------------------------------------------- 267*4bdff4beSrobertoption(LIBCXX_BUILD_32_BITS "Build 32 bit multilib libc++. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS}) 268*4bdff4beSrobertif (LIBCXX_BUILD_32_BITS) 269*4bdff4beSrobert message(FATAL_ERROR "LIBCXX_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.") 270*4bdff4beSrobertendif() 27146035553Spatrick 27246035553Spatrick# Feature options ------------------------------------------------------------- 27346035553Spatrickoption(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) 27446035553Spatrickoption(LIBCXX_ENABLE_RTTI "Use run time type information." ON) 27546035553Spatrickoption(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) 27646035553Spatrickoption(LIBCXX_ENABLE_MONOTONIC_CLOCK 27746035553Spatrick "Build libc++ with support for a monotonic clock. 27846035553Spatrick This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) 27946035553Spatrickoption(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) 28046035553Spatrickoption(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) 28146035553Spatrickoption(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF) 28246035553Spatrickoption(LIBCXX_HAS_EXTERNAL_THREAD_API 28346035553Spatrick "Build libc++ with an externalized threading API. 28446035553Spatrick This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) 28546035553Spatrickoption(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY 28646035553Spatrick "Build libc++ with an externalized threading library. 28746035553Spatrick This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) 28846035553Spatrick 28946035553Spatrick# Misc options ---------------------------------------------------------------- 29046035553Spatrick# FIXME: Turn -pedantic back ON. It is currently off because it warns 29146035553Spatrick# about #include_next which is used everywhere. 29246035553Spatrickoption(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) 29346035553Spatrickoption(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) 29446035553Spatrickoption(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) 29546035553Spatrick 29646035553Spatrickoption(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) 29746035553Spatrickset(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING 29846035553Spatrick "The Profile-rt library used to build with code coverage") 29946035553Spatrick 30046035553Spatrickset(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) 30146035553Spatrickif (XCODE OR MSVC_IDE) 30246035553Spatrick set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) 30346035553Spatrickendif() 30446035553Spatrickoption(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" 30546035553Spatrick ${LIBCXX_CONFIGURE_IDE_DEFAULT}) 30646035553Spatrick 307*4bdff4beSrobertset(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) 308*4bdff4beSrobertif (WIN32) 309*4bdff4beSrobert set(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT ON) 310*4bdff4beSrobertendif() 31146035553Spatrickoption(LIBCXX_HERMETIC_STATIC_LIBRARY 312*4bdff4beSrobert "Do not export any symbols from the static library." ${LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT}) 31346035553Spatrick 31446035553Spatrick#=============================================================================== 31546035553Spatrick# Check option configurations 31646035553Spatrick#=============================================================================== 31746035553Spatrick 31846035553Spatrick# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when 31946035553Spatrick# LIBCXX_ENABLE_THREADS is on. 32046035553Spatrickif(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) 32146035553Spatrick message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" 32246035553Spatrick " when LIBCXX_ENABLE_THREADS is also set to OFF.") 32346035553Spatrickendif() 32446035553Spatrick 32546035553Spatrickif(NOT LIBCXX_ENABLE_THREADS) 32646035553Spatrick if(LIBCXX_HAS_PTHREAD_API) 32746035553Spatrick message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" 32846035553Spatrick " when LIBCXX_ENABLE_THREADS is also set to ON.") 32946035553Spatrick endif() 33046035553Spatrick if(LIBCXX_HAS_EXTERNAL_THREAD_API) 33146035553Spatrick message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" 33246035553Spatrick " when LIBCXX_ENABLE_THREADS is also set to ON.") 33346035553Spatrick endif() 33446035553Spatrick if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) 33546035553Spatrick message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " 33646035553Spatrick "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") 33746035553Spatrick endif() 33846035553Spatrick if (LIBCXX_HAS_WIN32_THREAD_API) 33946035553Spatrick message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON" 34046035553Spatrick " when LIBCXX_ENABLE_THREADS is also set to ON.") 34146035553Spatrick endif() 34246035553Spatrick 34346035553Spatrickendif() 34446035553Spatrick 34546035553Spatrickif (LIBCXX_HAS_EXTERNAL_THREAD_API) 34646035553Spatrick if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) 34746035553Spatrick message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " 34846035553Spatrick "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " 34946035553Spatrick "the same time") 35046035553Spatrick endif() 35146035553Spatrick if (LIBCXX_HAS_PTHREAD_API) 35246035553Spatrick message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" 35346035553Spatrick "and LIBCXX_HAS_PTHREAD_API cannot be both" 35446035553Spatrick "set to ON at the same time.") 35546035553Spatrick endif() 35646035553Spatrick if (LIBCXX_HAS_WIN32_THREAD_API) 35746035553Spatrick message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" 35846035553Spatrick "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" 35946035553Spatrick "set to ON at the same time.") 36046035553Spatrick endif() 36146035553Spatrickendif() 36246035553Spatrick 36346035553Spatrickif (LIBCXX_HAS_PTHREAD_API) 36446035553Spatrick if (LIBCXX_HAS_WIN32_THREAD_API) 36546035553Spatrick message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API" 36646035553Spatrick "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" 36746035553Spatrick "set to ON at the same time.") 36846035553Spatrick endif() 36946035553Spatrickendif() 37046035553Spatrick 37146035553Spatrick# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE 37246035553Spatrick# is ON. 37346035553Spatrickif (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) 37446035553Spatrick message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") 37546035553Spatrickendif() 37646035553Spatrick 37746035553Spatrickif (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) 37846035553Spatrick if (APPLE) 37946035553Spatrick message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") 38046035553Spatrick endif() 38146035553Spatrick if (NOT LIBCXX_ENABLE_SHARED) 38246035553Spatrick message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") 38346035553Spatrick endif() 38446035553Spatrickendif() 38546035553Spatrick 38646035553Spatrickif (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) 38746035553Spatrick message(FATAL_ERROR "Conflicting options given. 388*4bdff4beSrobert LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY cannot be specified with 38946035553Spatrick LIBCXX_ENABLE_ABI_LINKER_SCRIPT") 39046035553Spatrickendif() 39146035553Spatrick 39246035553Spatrickif (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) 39346035553Spatrick message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") 39446035553Spatrickendif () 39546035553Spatrick 39646035553Spatrick#=============================================================================== 39746035553Spatrick# Configure System 39846035553Spatrick#=============================================================================== 39946035553Spatrick 40076d0caaeSpatrick# TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR 40176d0caaeSpatrick# instead of hard-coding include/c++/v1. 402*4bdff4beSrobert 403*4bdff4beSrobertset(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH 404*4bdff4beSrobert "Path where target-agnostic libc++ headers should be installed.") 405*4bdff4beSrobertset(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH 406*4bdff4beSrobert "Path where built libc++ runtime libraries should be installed.") 407*4bdff4beSrobert 408*4bdff4beSrobertset(LIBCXX_SHARED_OUTPUT_NAME "c++" CACHE STRING "Output name for the shared libc++ runtime library.") 409*4bdff4beSrobertset(LIBCXX_STATIC_OUTPUT_NAME "c++" CACHE STRING "Output name for the static libc++ runtime library.") 410*4bdff4beSrobert 41146035553Spatrickif(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) 41276d0caaeSpatrick set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) 41376d0caaeSpatrick set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 41476d0caaeSpatrick set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") 41576d0caaeSpatrick set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH 41676d0caaeSpatrick "Path where built libc++ libraries should be installed.") 417*4bdff4beSrobert set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH 41876d0caaeSpatrick "Path where target-specific libc++ headers should be installed.") 41946035553Spatrick if(LIBCXX_LIBDIR_SUBDIR) 42046035553Spatrick string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) 42146035553Spatrick string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) 42246035553Spatrick endif() 423*4bdff4beSrobertelse() 424*4bdff4beSrobert if(LLVM_LIBRARY_OUTPUT_INTDIR) 42546035553Spatrick set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) 42676d0caaeSpatrick set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") 42746035553Spatrick else() 42846035553Spatrick set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) 42976d0caaeSpatrick set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") 430*4bdff4beSrobert endif() 43176d0caaeSpatrick set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") 43276d0caaeSpatrick set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH 43376d0caaeSpatrick "Path where built libc++ libraries should be installed.") 43476d0caaeSpatrick set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH 43576d0caaeSpatrick "Path where target-specific libc++ headers should be installed.") 43646035553Spatrickendif() 43746035553Spatrick 43846035553Spatrickfile(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") 43946035553Spatrick 44046035553Spatrickset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) 44146035553Spatrickset(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) 44246035553Spatrickset(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) 44346035553Spatrick 44446035553Spatrick# Declare libc++ configuration variables. 44546035553Spatrick# They are intended for use as follows: 44646035553Spatrick# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. 44746035553Spatrick# LIBCXX_COMPILE_FLAGS: Compile only flags. 44846035553Spatrick# LIBCXX_LINK_FLAGS: Linker only flags. 44946035553Spatrick# LIBCXX_LIBRARIES: libraries libc++ is linked to. 45046035553Spatrickset(LIBCXX_COMPILE_FLAGS "") 45146035553Spatrickset(LIBCXX_LINK_FLAGS "") 45246035553Spatrickset(LIBCXX_LIBRARIES "") 453*4bdff4beSrobertset(LIBCXX_ADDITIONAL_COMPILE_FLAGS "" CACHE STRING 454*4bdff4beSrobert "Additional Compile only flags which can be provided in cache") 455*4bdff4beSrobertset(LIBCXX_ADDITIONAL_LIBRARIES "" CACHE STRING 456*4bdff4beSrobert "Additional libraries libc++ is linked to which can be provided in cache") 45746035553Spatrick 45846035553Spatrick# Include macros for adding and removing libc++ flags. 45946035553Spatrickinclude(HandleLibcxxFlags) 46046035553Spatrick 46146035553Spatrick# Target flags ================================================================ 46246035553Spatrick# These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that 46346035553Spatrick# 'config-ix' use them during feature checks. It also adds them to both 46446035553Spatrick# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' 46546035553Spatrick 466*4bdff4beSrobertif (${CMAKE_SYSTEM_NAME} MATCHES "AIX") 467*4bdff4beSrobert add_target_flags_if_supported("-mdefault-visibility-export-mapping=explicit") 468*4bdff4beSrobert set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF) 46946035553Spatrickendif() 47046035553Spatrick 47146035553Spatrick# Configure compiler. 47246035553Spatrickinclude(config-ix) 47346035553Spatrick 47446035553Spatrick# Configure coverage options. 47546035553Spatrickif (LIBCXX_GENERATE_COVERAGE) 47646035553Spatrick include(CodeCoverage) 47746035553Spatrick set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) 47846035553Spatrickendif() 47946035553Spatrick 48046035553Spatrickstring(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) 48146035553Spatrickif (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") 48246035553Spatrick set(LIBCXX_DEBUG_BUILD ON) 48346035553Spatrickelse() 48446035553Spatrick set(LIBCXX_DEBUG_BUILD OFF) 48546035553Spatrickendif() 48646035553Spatrick 48746035553Spatrick#=============================================================================== 48846035553Spatrick# Setup Compiler Flags 48946035553Spatrick#=============================================================================== 49046035553Spatrick 49146035553Spatrickinclude(HandleLibCXXABI) # Setup the ABI library flags 49246035553Spatrick 49346035553Spatrick# FIXME: Remove all debug flags and flags that change which Windows 49446035553Spatrick# default libraries are linked. Currently we only support linking the 49546035553Spatrick# non-debug DLLs 49646035553Spatrickremove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") 49746035553Spatrick 49846035553Spatrick# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. 49946035553Spatrick# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors 50046035553Spatrick# so they don't get transformed into -Wno and -errors respectively. 50146035553Spatrickremove_flags(-Wno-pedantic -pedantic-errors -pedantic) 50246035553Spatrick 50346035553Spatrick# Required flags ============================================================== 50446035553Spatrickfunction(cxx_add_basic_build_flags target) 50546035553Spatrick 50676d0caaeSpatrick # Require C++20 for all targets. C++17 is needed to use aligned allocation 50776d0caaeSpatrick # in the dylib. C++20 is needed to use char8_t. 50846035553Spatrick set_target_properties(${target} PROPERTIES 50976d0caaeSpatrick CXX_STANDARD 20 510*4bdff4beSrobert CXX_STANDARD_REQUIRED YES 51146035553Spatrick CXX_EXTENSIONS NO) 51246035553Spatrick 51376d0caaeSpatrick # When building the dylib, don't warn for unavailable aligned allocation 51476d0caaeSpatrick # functions based on the deployment target -- they are always available 515*4bdff4beSrobert # because they are provided by the dylib itself with the exception of z/OS. 51676d0caaeSpatrick if (ZOS) 51776d0caaeSpatrick target_add_compile_flags_if_supported(${target} PRIVATE -fno-aligned-allocation) 51876d0caaeSpatrick else() 51976d0caaeSpatrick target_add_compile_flags_if_supported(${target} PRIVATE -faligned-allocation) 52076d0caaeSpatrick endif() 52176d0caaeSpatrick 52246035553Spatrick # On all systems the system c++ standard library headers need to be excluded. 52346035553Spatrick # MSVC only has -X, which disables all default includes; including the crt. 52446035553Spatrick # Thus, we do nothing and hope we don't accidentally include any of the C++ 52546035553Spatrick # headers 52646035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -nostdinc++) 52746035553Spatrick 52846035553Spatrick # Hide all inline function definitions which have not explicitly been marked 52946035553Spatrick # visible. This prevents new definitions for inline functions from appearing in 53046035553Spatrick # the dylib when get ODR used by another function. 53146035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility-inlines-hidden) 53246035553Spatrick 53346035553Spatrick # Our visibility annotations are not quite right for non-Clang compilers, 53446035553Spatrick # so we end up not exporting all the symbols we should. In the future, we 53546035553Spatrick # can improve the situation by providing an explicit list of exported 53646035553Spatrick # symbols on all compilers. 53746035553Spatrick if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 53846035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden) 53946035553Spatrick endif() 54046035553Spatrick 54146035553Spatrick if (LIBCXX_CONFIGURE_IDE) 54246035553Spatrick # This simply allows IDE to process <experimental/coroutine> 54346035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -fcoroutines-ts) 54446035553Spatrick endif() 54546035553Spatrick 54646035553Spatrick # Let the library headers know they are currently being used to build the 54746035553Spatrick # library. 54846035553Spatrick target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY) 54946035553Spatrick 55046035553Spatrick if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) 55146035553Spatrick target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) 55246035553Spatrick endif() 55346035553Spatrick 554*4bdff4beSrobert if (C_SUPPORTS_COMMENT_LIB_PRAGMA) 55546035553Spatrick if (LIBCXX_HAS_PTHREAD_LIB) 55646035553Spatrick target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB) 55746035553Spatrick endif() 55846035553Spatrick if (LIBCXX_HAS_RT_LIB) 55946035553Spatrick target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB) 56046035553Spatrick endif() 56146035553Spatrick endif() 562*4bdff4beSrobert target_compile_options(${target} PUBLIC "${LIBCXX_ADDITIONAL_COMPILE_FLAGS}") 56346035553Spatrickendfunction() 56446035553Spatrick 56546035553Spatrick# Warning flags =============================================================== 56646035553Spatrickfunction(cxx_add_warning_flags target) 56746035553Spatrick target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 56876d0caaeSpatrick if (MSVC) 56976d0caaeSpatrick # -W4 is the cl.exe/clang-cl equivalent of -Wall. (In cl.exe and clang-cl, 57076d0caaeSpatrick # -Wall is equivalent to -Weverything in GCC style compiler drivers.) 57176d0caaeSpatrick target_add_compile_flags_if_supported(${target} PRIVATE -W4) 57276d0caaeSpatrick else() 57376d0caaeSpatrick target_add_compile_flags_if_supported(${target} PRIVATE -Wall) 57476d0caaeSpatrick endif() 57576d0caaeSpatrick target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings 57646035553Spatrick -Wno-unused-parameter -Wno-long-long 577*4bdff4beSrobert -Werror=return-type -Wextra-semi -Wundef 578*4bdff4beSrobert -Wformat-nonliteral) 57946035553Spatrick if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") 58046035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE 58146035553Spatrick -Wno-user-defined-literals 58246035553Spatrick -Wno-covered-switch-default 58376d0caaeSpatrick -Wno-suggest-override 58446035553Spatrick ) 58546035553Spatrick if (LIBCXX_TARGETING_CLANG_CL) 58646035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE 58746035553Spatrick -Wno-c++98-compat 58846035553Spatrick -Wno-c++98-compat-pedantic 58946035553Spatrick -Wno-c++11-compat 59046035553Spatrick -Wno-undef 59146035553Spatrick -Wno-reserved-id-macro 59246035553Spatrick -Wno-gnu-include-next 59346035553Spatrick -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings 59446035553Spatrick -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences. 59546035553Spatrick -Wno-deprecated-dynamic-exception-spec # For auto_ptr 59646035553Spatrick -Wno-sign-conversion 59746035553Spatrick -Wno-old-style-cast 59846035553Spatrick -Wno-deprecated # FIXME: Remove this and fix all occurrences. 59946035553Spatrick -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang? 60046035553Spatrick -Wno-double-promotion # FIXME: remove me 60146035553Spatrick ) 60246035553Spatrick endif() 60346035553Spatrick elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") 60446035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE 605*4bdff4beSrobert -Wno-attributes 60646035553Spatrick -Wno-literal-suffix 60746035553Spatrick -Wno-c++14-compat 60876d0caaeSpatrick -Wno-noexcept-type 60976d0caaeSpatrick -Wno-suggest-override) 61046035553Spatrick endif() 61146035553Spatrick if (LIBCXX_ENABLE_WERROR) 61246035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -Werror) 61346035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -WX) 61446035553Spatrick else() 61546035553Spatrick # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is 61646035553Spatrick # added elsewhere. 61746035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error) 61846035553Spatrick endif() 61946035553Spatrick if (LIBCXX_ENABLE_PEDANTIC) 62046035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE -pedantic) 62146035553Spatrick endif() 62246035553Spatrickendfunction() 62346035553Spatrick 62446035553Spatrick# Exception flags ============================================================= 62546035553Spatrickfunction(cxx_add_exception_flags target) 62646035553Spatrick if (LIBCXX_ENABLE_EXCEPTIONS) 62746035553Spatrick # Catches C++ exceptions only and tells the compiler to assume that extern C 62846035553Spatrick # functions never throw a C++ exception. 62946035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -EHsc) 63046035553Spatrick else() 63146035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-) 63246035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions) 63346035553Spatrick endif() 63446035553Spatrickendfunction() 63546035553Spatrick 63646035553Spatrick# RTTI flags ================================================================== 63746035553Spatrickfunction(cxx_add_rtti_flags target) 63846035553Spatrick if (NOT LIBCXX_ENABLE_RTTI) 63946035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -GR-) 64046035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti) 64146035553Spatrick endif() 64246035553Spatrickendfunction() 64346035553Spatrick 64446035553Spatrick# Threading flags ============================================================= 64546035553Spatrickif (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) 64646035553Spatrick # Need to allow unresolved symbols if this is to work with shared library builds 64746035553Spatrick if (APPLE) 64846035553Spatrick add_link_flags("-undefined dynamic_lookup") 64946035553Spatrick else() 65046035553Spatrick # Relax this restriction from HandleLLVMOptions 65146035553Spatrick string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 65246035553Spatrick endif() 65346035553Spatrickendif() 65446035553Spatrick 65546035553Spatrick# Assertion flags ============================================================= 65646035553Spatrickdefine_if(LIBCXX_DEBUG_BUILD -D_DEBUG) 65746035553Spatrickif (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) 65846035553Spatrick # MSVC doesn't like _DEBUG on release builds. See PR 4379. 65946035553Spatrick define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) 66046035553Spatrickendif() 66146035553Spatrick 66246035553Spatrick# Modules flags =============================================================== 66346035553Spatrick# FIXME The libc++ sources are fundamentally non-modular. They need special 66446035553Spatrick# versions of the headers in order to provide C++03 and legacy ABI definitions. 66546035553Spatrick# NOTE: The public headers can be used with modules in all other contexts. 66646035553Spatrickfunction(cxx_add_module_flags target) 66746035553Spatrick if (LLVM_ENABLE_MODULES) 66846035553Spatrick # Ignore that the rest of the modules flags are now unused. 66946035553Spatrick target_add_compile_flags_if_supported(${target} PUBLIC -Wno-unused-command-line-argument) 67046035553Spatrick target_compile_options(${target} PUBLIC -fno-modules) 67146035553Spatrick endif() 67246035553Spatrickendfunction() 67346035553Spatrick 67446035553Spatrick# Sanitizer flags ============================================================= 67546035553Spatrick 67646035553Spatrickfunction(get_sanitizer_flags OUT_VAR USE_SANITIZER) 67746035553Spatrick set(SANITIZER_FLAGS) 67846035553Spatrick set(USE_SANITIZER "${USE_SANITIZER}") 67946035553Spatrick # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. 68046035553Spatrick # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. 68146035553Spatrick if (USE_SANITIZER AND NOT MSVC) 68246035553Spatrick append_flags_if_supported(SANITIZER_FLAGS "-fno-omit-frame-pointer") 68346035553Spatrick append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") 68446035553Spatrick 68546035553Spatrick if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND 68646035553Spatrick NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") 68746035553Spatrick append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") 68846035553Spatrick endif() 68946035553Spatrick if (USE_SANITIZER STREQUAL "Address") 69046035553Spatrick append_flags(SANITIZER_FLAGS "-fsanitize=address") 691*4bdff4beSrobert elseif (USE_SANITIZER STREQUAL "HWAddress") 692*4bdff4beSrobert append_flags(SANITIZER_FLAGS "-fsanitize=hwaddress") 69346035553Spatrick elseif (USE_SANITIZER MATCHES "Memory(WithOrigins)?") 69446035553Spatrick append_flags(SANITIZER_FLAGS -fsanitize=memory) 69546035553Spatrick if (USE_SANITIZER STREQUAL "MemoryWithOrigins") 69646035553Spatrick append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins") 69746035553Spatrick endif() 69846035553Spatrick elseif (USE_SANITIZER STREQUAL "Undefined") 69946035553Spatrick append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") 700037e7968Spatrick elseif (USE_SANITIZER STREQUAL "Address;Undefined" OR 701037e7968Spatrick USE_SANITIZER STREQUAL "Undefined;Address") 702037e7968Spatrick append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") 70346035553Spatrick elseif (USE_SANITIZER STREQUAL "Thread") 70446035553Spatrick append_flags(SANITIZER_FLAGS -fsanitize=thread) 705037e7968Spatrick elseif (USE_SANITIZER STREQUAL "DataFlow") 706037e7968Spatrick append_flags(SANITIZER_FLAGS -fsanitize=dataflow) 70746035553Spatrick else() 70846035553Spatrick message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${USE_SANITIZER}") 70946035553Spatrick endif() 71046035553Spatrick elseif(USE_SANITIZER AND MSVC) 71146035553Spatrick message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") 71246035553Spatrick endif() 71346035553Spatrick set(${OUT_VAR} "${SANITIZER_FLAGS}" PARENT_SCOPE) 71446035553Spatrickendfunction() 71546035553Spatrick 71646035553Spatrickget_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}") 71746035553Spatrick 71846035553Spatrick# Link system libraries ======================================================= 71946035553Spatrickfunction(cxx_link_system_libraries target) 72076d0caaeSpatrick 72176d0caaeSpatrick# In order to remove just libc++ from the link step 72276d0caaeSpatrick# we need to use -nostdlib++ whenever it is supported. 72376d0caaeSpatrick# Unfortunately this cannot be used universally because for example g++ supports 72476d0caaeSpatrick# only -nodefaultlibs in which case all libraries will be removed and 72576d0caaeSpatrick# all libraries but c++ have to be added in manually. 726*4bdff4beSrobert if (CXX_SUPPORTS_NOSTDLIBXX_FLAG) 72776d0caaeSpatrick target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++") 72876d0caaeSpatrick else() 72946035553Spatrick target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") 73046035553Spatrick target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") 73146035553Spatrick target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") 73276d0caaeSpatrick endif() 73346035553Spatrick 734*4bdff4beSrobert if (CXX_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER) 735*4bdff4beSrobert # If we're linking directly against the libunwind that we're building 736*4bdff4beSrobert # in the same invocation, don't try to link in the toolchain's 737*4bdff4beSrobert # default libunwind (which may be missing still). 738*4bdff4beSrobert target_add_link_flags_if_supported(${target} PRIVATE "--unwindlib=none") 739*4bdff4beSrobert endif() 740*4bdff4beSrobert 74146035553Spatrick if (LIBCXX_HAS_SYSTEM_LIB) 74246035553Spatrick target_link_libraries(${target} PRIVATE System) 74346035553Spatrick endif() 74446035553Spatrick 74546035553Spatrick if (LIBCXX_HAS_PTHREAD_LIB) 74646035553Spatrick target_link_libraries(${target} PRIVATE pthread) 74746035553Spatrick endif() 74846035553Spatrick 74946035553Spatrick if (LIBCXX_HAS_C_LIB) 75046035553Spatrick target_link_libraries(${target} PRIVATE c) 75146035553Spatrick endif() 75246035553Spatrick 75346035553Spatrick if (LIBCXX_HAS_M_LIB) 75446035553Spatrick target_link_libraries(${target} PRIVATE m) 75546035553Spatrick endif() 75646035553Spatrick 75746035553Spatrick if (LIBCXX_HAS_RT_LIB) 75846035553Spatrick target_link_libraries(${target} PRIVATE rt) 75946035553Spatrick endif() 76046035553Spatrick 76146035553Spatrick if (LIBCXX_USE_COMPILER_RT) 76246035553Spatrick find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) 76346035553Spatrick if (LIBCXX_BUILTINS_LIBRARY) 76446035553Spatrick target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}") 76546035553Spatrick endif() 766037e7968Spatrick elseif (LIBCXX_HAS_GCC_LIB) 767037e7968Spatrick target_link_libraries(${target} PRIVATE gcc) 76846035553Spatrick elseif (LIBCXX_HAS_GCC_S_LIB) 76946035553Spatrick target_link_libraries(${target} PRIVATE gcc_s) 77046035553Spatrick endif() 77146035553Spatrick 772037e7968Spatrick if (LIBCXX_HAS_ATOMIC_LIB) 77346035553Spatrick target_link_libraries(${target} PRIVATE atomic) 77446035553Spatrick endif() 77546035553Spatrick 77646035553Spatrick if (MINGW) 77746035553Spatrick target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}") 77846035553Spatrick endif() 77946035553Spatrick 78046035553Spatrick if (LIBCXX_TARGETING_MSVC) 78146035553Spatrick if (LIBCXX_DEBUG_BUILD) 78246035553Spatrick set(LIB_SUFFIX "d") 78346035553Spatrick else() 78446035553Spatrick set(LIB_SUFFIX "") 78546035553Spatrick endif() 78646035553Spatrick 78746035553Spatrick target_link_libraries(${target} PRIVATE ucrt${LIB_SUFFIX}) # Universal C runtime 78846035553Spatrick target_link_libraries(${target} PRIVATE vcruntime${LIB_SUFFIX}) # C++ runtime 78946035553Spatrick target_link_libraries(${target} PRIVATE msvcrt${LIB_SUFFIX}) # C runtime startup files 79046035553Spatrick target_link_libraries(${target} PRIVATE msvcprt${LIB_SUFFIX}) # C++ standard library. Required for exception_ptr internals. 79146035553Spatrick # Required for standards-complaint wide character formatting functions 79246035553Spatrick # (e.g. `printfw`/`scanfw`) 79346035553Spatrick target_link_libraries(${target} PRIVATE iso_stdio_wide_specifiers) 79446035553Spatrick endif() 795037e7968Spatrick 796037e7968Spatrick if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21) 797037e7968Spatrick target_link_libraries(${target} PUBLIC android_support) 798037e7968Spatrick endif() 799*4bdff4beSrobert target_link_libraries(${target} PUBLIC "${LIBCXX_ADDITIONAL_LIBRARIES}") 80046035553Spatrickendfunction() 80146035553Spatrick 80246035553Spatrick# Windows-related flags ======================================================= 80346035553Spatrickfunction(cxx_add_windows_flags target) 80446035553Spatrick if(WIN32 AND NOT MINGW) 80546035553Spatrick target_compile_definitions(${target} PRIVATE 80646035553Spatrick # Ignore the -MSC_VER mismatch, as we may build 80746035553Spatrick # with a different compatibility version. 80846035553Spatrick _ALLOW_MSC_VER_MISMATCH 80946035553Spatrick # Don't check the msvcprt iterator debug levels 81046035553Spatrick # as we will define the iterator types; libc++ 81146035553Spatrick # uses a different macro to identify the debug 81246035553Spatrick # level. 81346035553Spatrick _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH 81446035553Spatrick # We are building the c++ runtime, don't pull in 81546035553Spatrick # msvcprt. 81646035553Spatrick _CRTBLD 81746035553Spatrick # Don't warn on the use of "deprecated" 81846035553Spatrick # "insecure" functions which are standards 81946035553Spatrick # specified. 82046035553Spatrick _CRT_SECURE_NO_WARNINGS 82146035553Spatrick # Use the ISO conforming behaviour for conversion 82246035553Spatrick # in printf, scanf. 82346035553Spatrick _CRT_STDIO_ISO_WIDE_SPECIFIERS) 824*4bdff4beSrobert # Clang-cl shared builds don't support the experimental library. 825*4bdff4beSrobert # To avoid linker errors the format_error destructor is inlined for the 826*4bdff4beSrobert # dylib. Users can never use format in this mode. 827*4bdff4beSrobert # TODO FMT Remove when format becomes mainline. 828*4bdff4beSrobert if (LIBCXX_ENABLE_SHARED) 829*4bdff4beSrobert target_compile_definitions(${target} PRIVATE 830*4bdff4beSrobert _LIBCPP_INLINE_FORMAT_ERROR_DTOR) 831*4bdff4beSrobert endif() 83246035553Spatrick endif() 83346035553Spatrickendfunction() 83446035553Spatrick 83546035553Spatrick# Configuration file flags ===================================================== 83646035553Spatrickconfig_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) 83746035553Spatrickconfig_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE) 83846035553Spatrickconfig_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM) 83946035553Spatrickconfig_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT) 84046035553Spatrickconfig_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) 84146035553Spatrickconfig_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) 84276d0caaeSpatrickif (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default") 843037e7968Spatrick config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION) 84446035553Spatrickendif() 84546035553Spatrickconfig_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) 84646035553Spatrickconfig_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) 84746035553Spatrickconfig_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32) 84846035553Spatrickconfig_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) 84946035553Spatrickconfig_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) 85046035553Spatrickconfig_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) 85146035553Spatrickconfig_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITHMS) 85276d0caaeSpatrickconfig_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) 85376d0caaeSpatrickconfig_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE) 85476d0caaeSpatrickconfig_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION) 855*4bdff4beSrobertconfig_define_if_not(LIBCXX_ENABLE_FSTREAM _LIBCPP_HAS_NO_FSTREAM) 856*4bdff4beSrobertconfig_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE) 857*4bdff4beSrobertconfig_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS) 85876d0caaeSpatrickconfig_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) 859*4bdff4beSrobertconfig_define_if(LIBCXX_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE) 860*4bdff4beSrobertif (LIBCXX_ENABLE_ASSERTIONS) 861*4bdff4beSrobert config_define(1 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT) 862*4bdff4beSrobertelse() 863*4bdff4beSrobert config_define(0 _LIBCPP_ENABLE_ASSERTIONS_DEFAULT) 864*4bdff4beSrobertendif() 86546035553Spatrick 86646035553Spatrickif (LIBCXX_ABI_DEFINES) 86746035553Spatrick set(abi_defines) 86846035553Spatrick foreach (abi_define ${LIBCXX_ABI_DEFINES}) 86946035553Spatrick if (NOT abi_define MATCHES "^_LIBCPP_ABI_") 87046035553Spatrick message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES") 87146035553Spatrick endif() 87246035553Spatrick list(APPEND abi_defines "#define ${abi_define}") 87346035553Spatrick endforeach() 87446035553Spatrick string(REPLACE ";" "\n" abi_defines "${abi_defines}") 87546035553Spatrick config_define(${abi_defines} _LIBCPP_ABI_DEFINES) 87646035553Spatrickendif() 87746035553Spatrick 878*4bdff4beSrobertif (LIBCXX_EXTRA_SITE_DEFINES) 879*4bdff4beSrobert set(extra_site_defines) 880*4bdff4beSrobert foreach (extra_site_define ${LIBCXX_EXTRA_SITE_DEFINES}) 881*4bdff4beSrobert # Allow defines such as DEFINE=VAL, transformed into "#define DEFINE VAL". 882*4bdff4beSrobert string(REPLACE "=" " " extra_site_define "${extra_site_define}") 883*4bdff4beSrobert list(APPEND extra_site_defines "#define ${extra_site_define}") 884*4bdff4beSrobert endforeach() 885*4bdff4beSrobert string(REPLACE ";" "\n" extra_site_defines "${extra_site_defines}") 886*4bdff4beSrobert config_define(${extra_site_defines} _LIBCPP_EXTRA_SITE_DEFINES) 887*4bdff4beSrobertendif() 888*4bdff4beSrobert 88946035553Spatrick# By default libc++ on Windows expects to use a shared library, which requires 89046035553Spatrick# the headers to use DLL import/export semantics. However when building a 89146035553Spatrick# static library only we modify the headers to disable DLL import/export. 89246035553Spatrickif (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) 89346035553Spatrick message(STATUS "Generating custom __config for non-DLL Windows build") 89446035553Spatrick config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) 89546035553Spatrickendif() 89646035553Spatrick 89776d0caaeSpatrickif (WIN32 AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY) 89876d0caaeSpatrick # If linking libcxxabi statically into libcxx, skip the dllimport attributes 89976d0caaeSpatrick # on symbols we refer to from libcxxabi. 90076d0caaeSpatrick add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) 90176d0caaeSpatrickendif() 90276d0caaeSpatrick 90346035553Spatrick# Setup all common build flags ================================================= 90446035553Spatrickfunction(cxx_add_common_build_flags target) 90546035553Spatrick cxx_add_basic_build_flags(${target}) 90646035553Spatrick cxx_add_warning_flags(${target}) 90746035553Spatrick cxx_add_windows_flags(${target}) 90846035553Spatrick cxx_add_exception_flags(${target}) 90946035553Spatrick cxx_add_rtti_flags(${target}) 91046035553Spatrick cxx_add_module_flags(${target}) 91146035553Spatrick cxx_link_system_libraries(${target}) 91246035553Spatrickendfunction() 91346035553Spatrick 91446035553Spatrick#=============================================================================== 91546035553Spatrick# Setup Source Code And Tests 91646035553Spatrick#=============================================================================== 91746035553Spatrickadd_subdirectory(include) 91846035553Spatrickadd_subdirectory(src) 91976d0caaeSpatrickadd_subdirectory(utils) 92046035553Spatrick 921*4bdff4beSrobertset(LIBCXX_TEST_DEPS "cxx_experimental") 92246035553Spatrick 92346035553Spatrickif (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) 92446035553Spatrick list(APPEND LIBCXX_TEST_DEPS cxx_external_threads) 92546035553Spatrickendif() 92646035553Spatrick 927*4bdff4beSrobertif (LIBCXX_ENABLE_CLANG_TIDY) 928*4bdff4beSrobert list(APPEND LIBCXX_TEST_DEPS cxx-tidy) 929*4bdff4beSrobertendif() 930*4bdff4beSrobert 93146035553Spatrickif (LIBCXX_INCLUDE_BENCHMARKS) 93246035553Spatrick add_subdirectory(benchmarks) 93346035553Spatrickendif() 93446035553Spatrick 93546035553Spatrickif (LIBCXX_INCLUDE_TESTS) 936037e7968Spatrick add_subdirectory(test) 93746035553Spatrick add_subdirectory(lib/abi) 938037e7968Spatrickendif() 93946035553Spatrick 94046035553Spatrickif (LIBCXX_INCLUDE_DOCS) 94146035553Spatrick add_subdirectory(docs) 94246035553Spatrickendif() 943