Eric Fiselier | d6fb02b | 2020-03-24 21:33:42 -0400 | [diff] [blame] | 1 | # See https://libcxx.llvm.org/docs/BuildingLibcxx.html for instructions on how |
| 2 | # to build libcxx with CMake. |
Eric Fiselier | 7d6b2ad | 2017-05-04 06:28:34 +0000 | [diff] [blame] | 3 | |
Louis Dionne | 19aec8c | 2020-03-12 18:01:20 -0400 | [diff] [blame] | 4 | if (NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxxabi") |
| 5 | message(FATAL_ERROR "libc++ now requires being built in a monorepo layout with libcxxabi available") |
| 6 | endif() |
| 7 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 8 | #=============================================================================== |
| 9 | # Setup Project |
| 10 | #=============================================================================== |
Louis Dionne | afa1afd | 2020-04-22 11:15:05 -0400 | [diff] [blame] | 11 | cmake_minimum_required(VERSION 3.13.4) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 12 | |
Eric Fiselier | 8e0dec7 | 2015-01-26 21:56:45 +0000 | [diff] [blame] | 13 | if(POLICY CMP0042) |
| 14 | cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default |
| 15 | endif() |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 16 | if(POLICY CMP0022) |
| 17 | cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang |
| 18 | endif() |
Eric Fiselier | 6a10864 | 2018-07-26 05:08:30 +0000 | [diff] [blame] | 19 | if(POLICY CMP0068) |
| 20 | cmake_policy(SET CMP0068 NEW) |
| 21 | set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) |
| 22 | endif() |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 23 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 24 | # Add path for custom modules |
| 25 | set(CMAKE_MODULE_PATH |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 26 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 27 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
Eric Fiselier | d888cf5 | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 28 | ${CMAKE_MODULE_PATH} |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 29 | ) |
| 30 | |
Dominik Montada | 8c03fdf | 2020-08-24 11:01:05 +0200 | [diff] [blame] | 31 | set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 32 | set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 33 | set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") |
| 34 | |
Jonas Hahnfeld | 66c60d9 | 2019-02-17 12:16:20 +0000 | [diff] [blame] | 35 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) |
Saleem Abdulrasool | 163333f | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 36 | project(libcxx CXX C) |
| 37 | |
| 38 | set(PACKAGE_NAME libcxx) |
Hans Wennborg | 7ab7b97 | 2020-07-15 11:40:53 +0200 | [diff] [blame] | 39 | set(PACKAGE_VERSION 12.0.0git) |
Saleem Abdulrasool | 163333f | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 40 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 41 | set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") |
Eric Fiselier | 28349f9 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 42 | |
Dominik Montada | 8c03fdf | 2020-08-24 11:01:05 +0200 | [diff] [blame] | 43 | # In a standalone build, we don't have llvm to automatically generate the |
| 44 | # llvm-lit script for us. So we need to provide an explicit directory that |
| 45 | # the configurator should write the script into. |
| 46 | set(LIBCXX_STANDALONE_BUILD 1) |
| 47 | set(LLVM_LIT_OUTPUT_DIR "${LIBCXX_BINARY_DIR}/bin") |
| 48 | |
Eric Fiselier | 28349f9 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 49 | # Find the LLVM sources and simulate LLVM CMake options. |
| 50 | include(HandleOutOfTreeLLVM) |
Eugene Zelenko | 772d114 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 51 | endif() |
Saleem Abdulrasool | 163333f | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 52 | |
Petr Hosek | daf3a69 | 2017-01-16 00:33:07 +0000 | [diff] [blame] | 53 | if (LIBCXX_STANDALONE_BUILD) |
Raul Tambre | 86bd8f8 | 2020-09-05 17:52:23 +0300 | [diff] [blame] | 54 | find_package(Python3 COMPONENTS Interpreter) |
| 55 | if(NOT Python3_Interpreter_FOUND) |
| 56 | message(WARNING "Python3 not found, using python2 as a fallback") |
| 57 | find_package(Python2 COMPONENTS Interpreter REQUIRED) |
| 58 | if(Python2_VERSION VERSION_LESS 2.7) |
| 59 | message(SEND_ERROR "Python 2.7 or newer is required") |
Saleem Abdulrasool | 88af3dd | 2020-04-28 19:50:12 +0000 | [diff] [blame] | 60 | endif() |
Saleem Abdulrasool | 88af3dd | 2020-04-28 19:50:12 +0000 | [diff] [blame] | 61 | |
Raul Tambre | 86bd8f8 | 2020-09-05 17:52:23 +0300 | [diff] [blame] | 62 | # Treat python2 as python3 |
| 63 | add_executable(Python3::Interpreter IMPORTED) |
| 64 | set_target_properties(Python3::Interpreter PROPERTIES |
| 65 | IMPORTED_LOCATION ${Python2_EXECUTABLE}) |
| 66 | set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) |
Petr Hosek | daf3a69 | 2017-01-16 00:33:07 +0000 | [diff] [blame] | 67 | endif() |
| 68 | endif() |
| 69 | |
Saleem Abdulrasool | 163333f | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 70 | # Require out of source build. |
| 71 | include(MacroEnsureOutOfSourceBuild) |
| 72 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( |
| 73 | "${PROJECT_NAME} requires an out of source build. Please create a separate |
| 74 | build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." |
| 75 | ) |
Eric Fiselier | 5e0b8fc | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 76 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") |
| 77 | message(STATUS "Configuring for clang-cl") |
| 78 | set(LIBCXX_TARGETING_CLANG_CL ON) |
| 79 | endif() |
Saleem Abdulrasool | 163333f | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 80 | |
Eric Fiselier | cc1f65c | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 81 | if (MSVC) |
| 82 | set(LIBCXX_TARGETING_MSVC ON) |
Eric Fiselier | 11edd93 | 2018-10-01 01:00:11 +0000 | [diff] [blame] | 83 | message(STATUS "Configuring for MSVC") |
Eric Fiselier | cc1f65c | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 84 | else() |
| 85 | set(LIBCXX_TARGETING_MSVC OFF) |
| 86 | endif() |
| 87 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 88 | #=============================================================================== |
| 89 | # Setup CMake Options |
| 90 | #=============================================================================== |
Eric Fiselier | 309a50a | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 91 | include(CMakeDependentOption) |
Eric Fiselier | 2aeac46 | 2017-03-11 03:24:18 +0000 | [diff] [blame] | 92 | include(HandleCompilerRT) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 93 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 94 | # Basic options --------------------------------------------------------------- |
Eric Fiselier | e49cdfb | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 95 | option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 96 | option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 97 | option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 98 | option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) |
Eric Fiselier | f1d87f8 | 2019-03-21 00:04:31 +0000 | [diff] [blame] | 99 | set(ENABLE_FILESYSTEM_DEFAULT ON) |
| 100 | if (WIN32) |
| 101 | set(ENABLE_FILESYSTEM_DEFAULT OFF) |
| 102 | endif() |
| 103 | option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library" |
| 104 | ${ENABLE_FILESYSTEM_DEFAULT}) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 105 | option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) |
Louis Dionne | 0a06eb9 | 2019-08-05 18:29:14 +0000 | [diff] [blame] | 106 | option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) |
Louis Dionne | 8776672 | 2020-10-09 14:40:47 -0400 | [diff] [blame] | 107 | option(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT |
Louis Dionne | ce1365f | 2020-10-06 16:46:58 -0400 | [diff] [blame] | 108 | "Whether to include support for libc++'s debugging mode in the library. |
| 109 | By default, this is turned on. If you turn it off and try to enable the |
| 110 | debug mode when compiling a program against libc++, it will fail to link |
| 111 | since the required support isn't provided in the library." ON) |
Louis Dionne | e0d0129 | 2020-10-15 10:32:09 -0400 | [diff] [blame] | 112 | option(LIBCXX_ENABLE_RANDOM_DEVICE |
| 113 | "Whether to include support for std::random_device in the library. Disabling |
| 114 | this can be useful when building the library for platforms that don't have |
| 115 | a source of randomness, such as some embedded platforms. When this is not |
| 116 | supported, most of <random> will still be available, but std::random_device |
| 117 | will not." ON) |
Louis Dionne | 88ffc72 | 2020-10-09 15:31:05 -0400 | [diff] [blame] | 118 | option(LIBCXX_ENABLE_LOCALIZATION |
| 119 | "Whether to include support for localization in the library. Disabling |
| 120 | localization can be useful when porting to platforms that don't support |
| 121 | the C locale API (e.g. embedded). When localization is not supported, |
| 122 | several parts of the library will be disabled: <iostream>, <regex>, <locale> |
| 123 | will be completely unusable, and other parts may be only partly available." ON) |
Louis Dionne | 2eadbc8 | 2020-11-04 15:01:25 -0500 | [diff] [blame] | 124 | option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS |
| 125 | "Whether to turn on vendor availability annotations on declarations that depend |
| 126 | on definitions in a shared library. By default, we assume that we're not building |
| 127 | libc++ for any specific vendor, and we disable those annotations. Vendors wishing |
| 128 | to provide compile-time errors when using features unavailable on some version of |
| 129 | the shared library they shipped should turn this on and see `include/__availability` |
| 130 | for more details." OFF) |
Louis Dionne | f9ca205 | 2020-08-29 17:13:02 -0400 | [diff] [blame] | 131 | set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/legacy.cfg.in" CACHE STRING |
Louis Dionne | c2f6a00 | 2020-09-08 11:29:32 -0400 | [diff] [blame] | 132 | "The Lit testing configuration to use when running the tests.") |
Louis Dionne | 6f69318 | 2020-07-09 11:54:09 -0400 | [diff] [blame] | 133 | set(LIBCXX_TEST_PARAMS "" CACHE STRING |
| 134 | "A list of parameters to run the Lit test suite with.") |
Eric Fiselier | 3aa5478 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 135 | |
Eric Fiselier | 3aa5478 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 136 | # Benchmark options ----------------------------------------------------------- |
Louis Dionne | 9553008 | 2018-09-22 21:30:12 +0000 | [diff] [blame] | 137 | option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) |
Eric Fiselier | 336a1a6 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 138 | |
| 139 | set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) |
| 140 | set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING |
| 141 | "Arguments to pass when running the benchmarks using check-cxx-benchmarks") |
| 142 | |
Eric Fiselier | 3aa5478 | 2016-10-30 22:53:00 +0000 | [diff] [blame] | 143 | set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING |
| 144 | "Build the benchmarks against the specified native STL. |
| 145 | The value must be one of libc++/libstdc++") |
| 146 | set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING |
| 147 | "Use alternate GCC toolchain when building the native benchmarks") |
| 148 | |
| 149 | if (LIBCXX_BENCHMARK_NATIVE_STDLIB) |
| 150 | if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" |
| 151 | OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) |
| 152 | message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " |
| 153 | "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") |
| 154 | endif() |
| 155 | endif() |
| 156 | |
Eric Fiselier | b17bb06 | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 157 | option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 158 | set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING |
| 159 | "Define suffix of library directory name (32/64)") |
| 160 | option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 161 | option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) |
Petr Hosek | 4a1e14e | 2018-07-24 23:27:51 +0000 | [diff] [blame] | 162 | cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY |
| 163 | "Install the static libc++ library." ON |
| 164 | "LIBCXX_ENABLE_STATIC;LIBCXX_INSTALL_LIBRARY" OFF) |
| 165 | cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY |
| 166 | "Install the shared libc++ library." ON |
| 167 | "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) |
Eric Fiselier | 309a50a | 2016-09-07 01:15:10 +0000 | [diff] [blame] | 168 | cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY |
| 169 | "Install libc++experimental.a" ON |
| 170 | "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) |
Eric Fiselier | 998a5c8 | 2018-07-27 03:07:09 +0000 | [diff] [blame] | 171 | |
Louis Dionne | f9a5290 | 2018-09-26 08:24:51 +0000 | [diff] [blame] | 172 | set(LIBCXX_ABI_VERSION "1" CACHE STRING "ABI version of libc++. Can be either 1 or 2, where 2 is currently not stable. Defaults to 1.") |
Eric Fiselier | fe13c13 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 173 | set(LIBCXX_ABI_NAMESPACE "" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") |
Evgeniy Stepanov | a66a7b3 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 174 | option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) |
Shoaib Meenai | a4a3d40 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 175 | option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.") |
| 176 | option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.") |
Eric Fiselier | 2405bd6 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 177 | |
Louis Dionne | be00e88 | 2020-11-16 18:13:43 -0500 | [diff] [blame^] | 178 | set(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "default" CACHE STRING |
| 179 | "Override the implementation to use for comparing typeinfos. By default, this |
| 180 | is detected automatically by the library, but this option allows overriding |
| 181 | which implementation is used unconditionally. |
Eric Fiselier | 2405bd6 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 182 | |
Louis Dionne | be00e88 | 2020-11-16 18:13:43 -0500 | [diff] [blame^] | 183 | See the documentation in <libcxx/include/typeinfo> for details on what each |
| 184 | value means.") |
| 185 | set(TYPEINFO_COMPARISON_VALUES "default;1;2;3") |
| 186 | if (NOT ("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" IN_LIST TYPEINFO_COMPARISON_VALUES)) |
Louis Dionne | d0fcdcd | 2020-05-15 15:58:19 -0400 | [diff] [blame] | 187 | message(FATAL_ERROR "Value '${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}' is not a valid value for |
Louis Dionne | be00e88 | 2020-11-16 18:13:43 -0500 | [diff] [blame^] | 188 | LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION") |
Eric Fiselier | 2405bd6 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 189 | endif() |
| 190 | |
Louis Dionne | 61cd687 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 191 | option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF) |
Shoaib Meenai | 8993753 | 2017-10-04 23:51:57 +0000 | [diff] [blame] | 192 | set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.") |
Saleem Abdulrasool | e81fcb8 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 193 | option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) |
Louis Dionne | 2d0b4d6 | 2019-03-20 18:16:24 +0000 | [diff] [blame] | 194 | set(LIBCXX_LIBCPPABI_VERSION "2" CACHE STRING "Version of libc++abi's ABI to re-export from libc++ when re-exporting is enabled. |
| 195 | Note that this is not related to the version of libc++'s ABI itself!") |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 196 | |
| 197 | # ABI Library options --------------------------------------------------------- |
Louis Dionne | 61e8973 | 2020-04-02 02:09:23 -0400 | [diff] [blame] | 198 | set(LIBCXX_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.") |
Eric Fiselier | 1cd196e | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 199 | set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 200 | set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) |
| 201 | |
Eric Fiselier | bb90685 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 202 | # Setup the default options if LIBCXX_CXX_ABI is not specified. |
Eric Fiselier | 1285e4d | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 203 | if (LIBCXX_CXX_ABI STREQUAL "default") |
Shoaib Meenai | 8048b44 | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 204 | if (LIBCXX_TARGETING_MSVC) |
| 205 | # FIXME: Figure out how to configure the ABI library on Windows. |
| 206 | set(LIBCXX_CXX_ABI_LIBNAME "vcruntime") |
Dimitry Andric | 35479ff | 2018-02-11 22:31:05 +0000 | [diff] [blame] | 207 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") |
| 208 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxrt") |
Louis Dionne | 61e8973 | 2020-04-02 02:09:23 -0400 | [diff] [blame] | 209 | elseif (NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) |
| 210 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
Eugene Zelenko | 772d114 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 211 | else() |
Shoaib Meenai | 8048b44 | 2017-04-20 23:33:49 +0000 | [diff] [blame] | 212 | set(LIBCXX_CXX_ABI_LIBNAME "default") |
Eugene Zelenko | 772d114 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 213 | endif() |
| 214 | else() |
Eric Fiselier | bb90685 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 215 | set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") |
Eugene Zelenko | 772d114 | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 216 | endif() |
Eric Fiselier | bb90685 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 217 | |
Louis Dionne | 0c962cb | 2019-03-18 18:18:01 +0000 | [diff] [blame] | 218 | option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY |
| 219 | "Use a static copy of the ABI library when linking libc++. |
| 220 | This option cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT." OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 221 | |
Petr Hosek | 058c04c | 2018-07-24 07:06:17 +0000 | [diff] [blame] | 222 | cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY |
| 223 | "Statically link the ABI library to static library" ON |
| 224 | "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_STATIC" OFF) |
| 225 | |
| 226 | cmake_dependent_option(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY |
| 227 | "Statically link the ABI library to shared library" ON |
Martin Storsjo | 3d2e5432 | 2018-08-14 17:33:10 +0000 | [diff] [blame] | 228 | "LIBCXX_ENABLE_STATIC_ABI_LIBRARY;LIBCXX_ENABLE_SHARED" OFF) |
Petr Hosek | 058c04c | 2018-07-24 07:06:17 +0000 | [diff] [blame] | 229 | |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 230 | # Generate and install a linker script inplace of libc++.so. The linker script |
Eric Fiselier | 1ab69fc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 231 | # will link libc++ to the correct ABI library. This option is on by default |
Shoaib Meenai | 84904fb | 2017-03-25 03:22:35 +0000 | [diff] [blame] | 232 | # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' |
Eric Fiselier | 571367e | 2015-10-22 20:50:07 +0000 | [diff] [blame] | 233 | # is on. This option is also disabled when the ABI library is not specified |
| 234 | # or is specified to be "none". |
Eric Fiselier | 1ab69fc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 235 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) |
Petr Hosek | 4b59ed4 | 2018-07-26 05:10:24 +0000 | [diff] [blame] | 236 | if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY |
Eric Fiselier | bb90685 | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 237 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" |
Eric Fiselier | 1285e4d | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 238 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" |
Saleem Abdulrasool | 216833b | 2020-04-29 01:37:28 +0000 | [diff] [blame] | 239 | AND Python3_EXECUTABLE |
Asiri Rathnayake | 28383a4 | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 240 | AND LIBCXX_ENABLE_SHARED) |
Eric Fiselier | 1ab69fc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 241 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) |
| 242 | endif() |
| 243 | |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 244 | option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT |
Eric Fiselier | 1ab69fc | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 245 | "Use and install a linker script for the given ABI library" |
Eric Fiselier | a15785b | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 246 | ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 247 | |
Eric Fiselier | 3499263 | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 248 | option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS |
Louis Dionne | 9b40ee8 | 2019-10-01 09:34:58 -0400 | [diff] [blame] | 249 | "Build libc++ with definitions for operator new/delete. These are normally |
| 250 | defined in libc++abi, but this option can be used to define them in libc++ |
| 251 | instead. If you define them in libc++, make sure they are NOT defined in |
| 252 | libc++abi. Doing otherwise is an ODR violation." OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 253 | # Build libc++abi with libunwind. We need this option to determine whether to |
| 254 | # link with libunwind or libgcc_s while running the test cases. |
| 255 | option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) |
| 256 | |
| 257 | # Target options -------------------------------------------------------------- |
| 258 | option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) |
Petr Hosek | 6fd4e7f | 2019-02-04 20:02:26 +0000 | [diff] [blame] | 259 | set(LIBCXX_TARGET_TRIPLE "" CACHE STRING "Use alternate target triple.") |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 260 | set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") |
| 261 | set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") |
| 262 | |
| 263 | # Feature options ------------------------------------------------------------- |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 264 | option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) |
| 265 | option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) |
Ed Schouten | 97fdea6 | 2015-03-12 15:44:39 +0000 | [diff] [blame] | 266 | option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) |
Ed Schouten | f4ac884 | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 267 | option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) |
| 268 | option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) |
Eric Fiselier | b9f9973 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 269 | option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) |
Ed Schouten | e0cf3b9 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 270 | option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) |
Eric Fiselier | b9f9973 | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 271 | option(LIBCXX_ENABLE_MONOTONIC_CLOCK |
| 272 | "Build libc++ with support for a monotonic clock. |
Jonathan Roelofs | 91b3a5e | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 273 | This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) |
Vasileios Kalintiris | 8c58e92 | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 274 | option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) |
Ben Craig | b9599b1 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 275 | option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) |
Martin Storsjo | bf02a09 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 276 | option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF) |
Asiri Rathnayake | 8c2bf45 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 277 | option(LIBCXX_HAS_EXTERNAL_THREAD_API |
| 278 | "Build libc++ with an externalized threading API. |
| 279 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) |
Eric Fiselier | 00f6bea | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 280 | option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY |
| 281 | "Build libc++ with an externalized threading library. |
| 282 | This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 283 | |
| 284 | # Misc options ---------------------------------------------------------------- |
Eric Fiselier | 6fb770a | 2015-10-10 03:34:52 +0000 | [diff] [blame] | 285 | # FIXME: Turn -pedantic back ON. It is currently off because it warns |
| 286 | # about #include_next which is used everywhere. |
| 287 | option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 288 | option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
Saleem Abdulrasool | 6fe3073 | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 289 | option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 290 | |
Eric Fiselier | 78fdf2d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 291 | option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) |
| 292 | set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 293 | "The Profile-rt library used to build with code coverage") |
| 294 | |
Eric Fiselier | 6627c70 | 2015-12-16 23:41:05 +0000 | [diff] [blame] | 295 | set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) |
| 296 | if (XCODE OR MSVC_IDE) |
| 297 | set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) |
| 298 | endif() |
| 299 | option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" |
| 300 | ${LIBCXX_CONFIGURE_IDE_DEFAULT}) |
| 301 | |
Petr Hosek | a2685cd | 2019-01-06 06:14:31 +0000 | [diff] [blame] | 302 | option(LIBCXX_HERMETIC_STATIC_LIBRARY |
| 303 | "Do not export any symbols from the static library." OFF) |
| 304 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 305 | #=============================================================================== |
| 306 | # Check option configurations |
| 307 | #=============================================================================== |
| 308 | |
| 309 | # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when |
| 310 | # LIBCXX_ENABLE_THREADS is on. |
| 311 | if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) |
| 312 | message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" |
| 313 | " when LIBCXX_ENABLE_THREADS is also set to OFF.") |
Eric Fiselier | 0058c80 | 2014-08-18 05:03:46 +0000 | [diff] [blame] | 314 | endif() |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 315 | |
Asiri Rathnayake | 205d7d3 | 2017-01-03 12:59:50 +0000 | [diff] [blame] | 316 | if(NOT LIBCXX_ENABLE_THREADS) |
| 317 | if(LIBCXX_HAS_PTHREAD_API) |
| 318 | message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" |
| 319 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 320 | endif() |
| 321 | if(LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 322 | message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" |
| 323 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 324 | endif() |
Eric Fiselier | 00f6bea | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 325 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 326 | message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " |
| 327 | "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 328 | endif() |
Martin Storsjo | bf02a09 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 329 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 330 | message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON" |
| 331 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 332 | endif() |
Eric Fiselier | 00f6bea | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 333 | |
| 334 | endif() |
| 335 | |
Asiri Rathnayake | b71c899 | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 336 | if (LIBCXX_HAS_EXTERNAL_THREAD_API) |
| 337 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 338 | message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " |
| 339 | "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " |
| 340 | "the same time") |
| 341 | endif() |
| 342 | if (LIBCXX_HAS_PTHREAD_API) |
| 343 | message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" |
| 344 | "and LIBCXX_HAS_PTHREAD_API cannot be both" |
| 345 | "set to ON at the same time.") |
| 346 | endif() |
Martin Storsjo | bf02a09 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 347 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 348 | message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" |
| 349 | "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" |
| 350 | "set to ON at the same time.") |
| 351 | endif() |
| 352 | endif() |
| 353 | |
| 354 | if (LIBCXX_HAS_PTHREAD_API) |
| 355 | if (LIBCXX_HAS_WIN32_THREAD_API) |
| 356 | message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API" |
| 357 | "and LIBCXX_HAS_WIN32_THREAD_API cannot be both" |
| 358 | "set to ON at the same time.") |
| 359 | endif() |
Asiri Rathnayake | 8c2bf45 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 360 | endif() |
| 361 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 362 | # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE |
| 363 | # is ON. |
| 364 | if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) |
| 365 | message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") |
| 366 | endif() |
| 367 | |
| 368 | # Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) |
| 369 | # and check that we can build with 32 bits if requested. |
| 370 | if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) |
| 371 | if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM |
| 372 | message(STATUS "Building 32 bits executables and libraries.") |
| 373 | endif() |
| 374 | elseif(LIBCXX_BUILD_32_BITS) |
| 375 | message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") |
| 376 | endif() |
| 377 | |
Louis Dionne | 9760737 | 2019-03-25 14:56:29 +0000 | [diff] [blame] | 378 | # Warn users that LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option. |
Eric Fiselier | 0357171 | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 379 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
Louis Dionne | 9760737 | 2019-03-25 14:56:29 +0000 | [diff] [blame] | 380 | message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") |
Saleem Abdulrasool | 216833b | 2020-04-29 01:37:28 +0000 | [diff] [blame] | 381 | if (LIBCXX_ENABLE_STATIC AND NOT Python3_EXECUTABLE) |
Eric Fiselier | bf58c8e | 2016-11-18 19:53:45 +0000 | [diff] [blame] | 382 | message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.") |
| 383 | endif() |
Eric Fiselier | 0357171 | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 384 | endif() |
| 385 | |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 386 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 387 | if (APPLE) |
| 388 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") |
| 389 | endif() |
Asiri Rathnayake | 28383a4 | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 390 | if (NOT LIBCXX_ENABLE_SHARED) |
| 391 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") |
| 392 | endif() |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 393 | endif() |
| 394 | |
Petr Hosek | 4b59ed4 | 2018-07-26 05:10:24 +0000 | [diff] [blame] | 395 | if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
Eric Fiselier | 8241405 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 396 | message(FATAL_ERROR "Conflicting options given. |
| 397 | LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with |
| 398 | LIBCXX_ENABLE_ABI_LINKER_SCRIPT") |
| 399 | endif() |
| 400 | |
Shoaib Meenai | a4a3d40 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 401 | if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) |
| 402 | message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") |
Shoaib Meenai | d456385 | 2017-10-04 23:44:38 +0000 | [diff] [blame] | 403 | endif () |
| 404 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 405 | #=============================================================================== |
| 406 | # Configure System |
| 407 | #=============================================================================== |
| 408 | |
Petr Hosek | 887f26d | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 409 | if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 410 | set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) |
Louis Dionne | 48e4b0f | 2020-10-23 09:32:50 -0400 | [diff] [blame] | 411 | set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 412 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) |
| 413 | if(LIBCXX_LIBDIR_SUBDIR) |
| 414 | string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) |
| 415 | string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) |
| 416 | endif() |
Petr Hosek | 887f26d | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 417 | elseif(LLVM_LIBRARY_OUTPUT_INTDIR) |
Jonas Hahnfeld | 98a7f27 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 418 | set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) |
Louis Dionne | 48e4b0f | 2020-10-23 09:32:50 -0400 | [diff] [blame] | 419 | set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 420 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) |
Jonas Hahnfeld | 98a7f27 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 421 | else() |
| 422 | set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) |
Louis Dionne | 48e4b0f | 2020-10-23 09:32:50 -0400 | [diff] [blame] | 423 | set(LIBCXX_HEADER_DIR ${CMAKE_BINARY_DIR}) |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 424 | set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) |
Jonas Hahnfeld | 98a7f27 | 2017-05-04 06:02:50 +0000 | [diff] [blame] | 425 | endif() |
Petr Hosek | 887f26d | 2018-06-28 03:11:52 +0000 | [diff] [blame] | 426 | |
Eric Fiselier | 1cd196e | 2017-01-16 20:47:35 +0000 | [diff] [blame] | 427 | file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") |
Eric Fiselier | a78a267 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 428 | |
Petr Hosek | 81f433b | 2019-05-22 21:08:33 +0000 | [diff] [blame] | 429 | set(LIBCXX_INSTALL_PREFIX "" CACHE STRING "Define libc++ destination prefix.") |
| 430 | set(LIBCXX_INSTALL_HEADER_PREFIX "" CACHE STRING "Define libc++ header destination prefix.") |
Petr Hosek | 510e70f | 2017-07-11 02:39:50 +0000 | [diff] [blame] | 431 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 432 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
| 433 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Shoaib Meenai | 6170765 | 2017-04-13 16:27:38 +0000 | [diff] [blame] | 434 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 435 | |
Eric Fiselier | 5aedca9 | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 436 | # Declare libc++ configuration variables. |
| 437 | # They are intended for use as follows: |
| 438 | # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. |
| 439 | # LIBCXX_COMPILE_FLAGS: Compile only flags. |
| 440 | # LIBCXX_LINK_FLAGS: Linker only flags. |
Eric Fiselier | 054fc4c | 2016-10-09 21:34:03 +0000 | [diff] [blame] | 441 | # LIBCXX_LIBRARIES: libraries libc++ is linked to. |
Eric Fiselier | 5aedca9 | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 442 | set(LIBCXX_COMPILE_FLAGS "") |
| 443 | set(LIBCXX_LINK_FLAGS "") |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 444 | set(LIBCXX_LIBRARIES "") |
Eric Fiselier | 5aedca9 | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 445 | |
Eric Fiselier | a4f2460 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 446 | # Include macros for adding and removing libc++ flags. |
| 447 | include(HandleLibcxxFlags) |
| 448 | |
| 449 | # Target flags ================================================================ |
| 450 | # These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that |
| 451 | # 'config-ix' use them during feature checks. It also adds them to both |
| 452 | # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' |
| 453 | add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") |
Petr Hosek | 6fd4e7f | 2019-02-04 20:02:26 +0000 | [diff] [blame] | 454 | |
| 455 | if(LIBCXX_TARGET_TRIPLE) |
| 456 | add_target_flags("--target=${LIBCXX_TARGET_TRIPLE}") |
| 457 | elseif(CMAKE_CXX_COMPILER_TARGET) |
| 458 | set(LIBCXX_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") |
| 459 | endif() |
| 460 | if(LIBCXX_SYSROOT) |
| 461 | add_target_flags("--sysroot=${LIBCXX_SYSROOT}") |
| 462 | elseif(CMAKE_SYSROOT) |
| 463 | set(LIBCXX_SYSROOT "${CMAKE_SYSROOT}") |
| 464 | endif() |
| 465 | if(LIBCXX_GCC_TOOLCHAIN) |
| 466 | add_target_flags("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") |
| 467 | elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) |
| 468 | set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") |
| 469 | endif() |
| 470 | |
| 471 | if(LIBCXX_TARGET_TRIPLE) |
Eric Fiselier | 79ff8f03 | 2016-11-13 22:27:00 +0000 | [diff] [blame] | 472 | set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") |
| 473 | endif() |
Eric Fiselier | a4f2460 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 474 | |
Eric Fiselier | 382338d | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 475 | # Configure compiler. |
| 476 | include(config-ix) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 477 | |
Eric Fiselier | 78fdf2d | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 478 | # Configure coverage options. |
| 479 | if (LIBCXX_GENERATE_COVERAGE) |
| 480 | include(CodeCoverage) |
| 481 | set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) |
| 482 | endif() |
Eric Fiselier | 382338d | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 483 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 484 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
Eric Fiselier | 7e3ee09 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 485 | if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") |
| 486 | set(LIBCXX_DEBUG_BUILD ON) |
| 487 | else() |
| 488 | set(LIBCXX_DEBUG_BUILD OFF) |
| 489 | endif() |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 490 | |
Eric Fiselier | 382338d | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 491 | #=============================================================================== |
| 492 | # Setup Compiler Flags |
| 493 | #=============================================================================== |
| 494 | |
JF Bastien | fc45f32 | 2016-03-05 14:22:02 +0000 | [diff] [blame] | 495 | include(HandleLibCXXABI) # Setup the ABI library flags |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 496 | |
Michal Gorny | ecc8864 | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 497 | if (NOT LIBCXX_STANDALONE_BUILD) |
| 498 | # Remove flags that may have snuck in. |
| 499 | remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG |
Eric Fiselier | 6dede18 | 2017-01-17 23:27:56 +0000 | [diff] [blame] | 500 | -lc++abi) |
Michal Gorny | ecc8864 | 2016-09-27 07:55:26 +0000 | [diff] [blame] | 501 | endif() |
Raphael Isemann | 6b7a49b | 2020-10-13 16:05:00 +0200 | [diff] [blame] | 502 | remove_flags(--stdlib=libc++ -stdlib=libc++ --stdlib=libstdc++ -stdlib=libstdc++) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 503 | |
Eric Fiselier | cc1f65c | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 504 | # FIXME: Remove all debug flags and flags that change which Windows |
| 505 | # default libraries are linked. Currently we only support linking the |
| 506 | # non-debug DLLs |
Eric Fiselier | 7e3ee09 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 507 | remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") |
Eric Fiselier | cc1f65c | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 508 | |
Shoaib Meenai | f88923d | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 509 | # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. |
Eric Fiselier | f2be7c2 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 510 | # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors |
Shoaib Meenai | f88923d | 2017-03-25 03:42:20 +0000 | [diff] [blame] | 511 | # so they don't get transformed into -Wno and -errors respectively. |
Eric Fiselier | f2be7c2 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 512 | remove_flags(-Wno-pedantic -pedantic-errors -pedantic) |
Eric Fiselier | f4bfd7c | 2015-10-13 23:56:33 +0000 | [diff] [blame] | 513 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 514 | # Required flags ============================================================== |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 515 | function(cxx_add_basic_build_flags target) |
Eric Fiselier | 72b41e6 | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 516 | |
Louis Dionne | e586607 | 2020-04-22 11:15:05 -0400 | [diff] [blame] | 517 | # Require C++17 for all targets. C++17 is needed to use aligned allocation |
| 518 | # in the dylib. |
Eric Fiselier | 72b41e6 | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 519 | set_target_properties(${target} PROPERTIES |
Louis Dionne | e586607 | 2020-04-22 11:15:05 -0400 | [diff] [blame] | 520 | CXX_STANDARD 17 |
Eric Fiselier | 72b41e6 | 2019-12-11 20:26:30 -0500 | [diff] [blame] | 521 | CXX_STANDARD_REQUIRED YES |
| 522 | CXX_EXTENSIONS NO) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 523 | |
Louis Dionne | 918ba93 | 2020-07-23 11:05:47 -0400 | [diff] [blame] | 524 | # When building the dylib, don't warn for unavailable aligned allocation |
| 525 | # functions based on the deployment target -- they are always available |
Zbigniew Sarbinowski | aa8a5b8 | 2020-11-12 14:40:35 -0500 | [diff] [blame] | 526 | # because they are provided by the dylib itself with the excepton of z/OS. |
| 527 | if (ZOS) |
| 528 | target_add_compile_flags_if_supported(${target} PRIVATE -fno-aligned-allocation) |
| 529 | else() |
| 530 | target_add_compile_flags_if_supported(${target} PRIVATE -faligned-allocation) |
| 531 | endif() |
Louis Dionne | 918ba93 | 2020-07-23 11:05:47 -0400 | [diff] [blame] | 532 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 533 | # On all systems the system c++ standard library headers need to be excluded. |
| 534 | # MSVC only has -X, which disables all default includes; including the crt. |
| 535 | # Thus, we do nothing and hope we don't accidentally include any of the C++ |
| 536 | # headers |
| 537 | target_add_compile_flags_if_supported(${target} PUBLIC -nostdinc++) |
Eric Fiselier | ff16b9a | 2015-07-29 21:07:28 +0000 | [diff] [blame] | 538 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 539 | # Hide all inline function definitions which have not explicitly been marked |
| 540 | # visible. This prevents new definitions for inline functions from appearing in |
| 541 | # the dylib when get ODR used by another function. |
| 542 | target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility-inlines-hidden) |
Eric Fiselier | 10b12f0 | 2016-10-25 19:43:44 +0000 | [diff] [blame] | 543 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 544 | # Our visibility annotations are not quite right for non-Clang compilers, |
| 545 | # so we end up not exporting all the symbols we should. In the future, we |
| 546 | # can improve the situation by providing an explicit list of exported |
| 547 | # symbols on all compilers. |
| 548 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 549 | target_add_compile_flags_if_supported(${target} PRIVATE -fvisibility=hidden) |
| 550 | endif() |
Eric Fiselier | 3ca9185 | 2017-05-25 04:36:24 +0000 | [diff] [blame] | 551 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 552 | if (LIBCXX_CONFIGURE_IDE) |
| 553 | # This simply allows IDE to process <experimental/coroutine> |
| 554 | target_add_compile_flags_if_supported(${target} PRIVATE -fcoroutines-ts) |
| 555 | endif() |
Eric Fiselier | f8f31c4 | 2016-09-16 00:00:48 +0000 | [diff] [blame] | 556 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 557 | # Let the library headers know they are currently being used to build the |
| 558 | # library. |
| 559 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_BUILDING_LIBRARY) |
Eric Fiselier | 3499263 | 2017-03-02 19:35:33 +0000 | [diff] [blame] | 560 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 561 | if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) |
| 562 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) |
| 563 | endif() |
| 564 | |
| 565 | if (LIBCXX_HAS_COMMENT_LIB_PRAGMA) |
Michał Górny | a9b5fff | 2019-12-02 11:49:20 +0100 | [diff] [blame] | 566 | if (LIBCXX_HAS_PTHREAD_LIB) |
| 567 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_PTHREAD_LIB) |
| 568 | endif() |
| 569 | if (LIBCXX_HAS_RT_LIB) |
| 570 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_LINK_RT_LIB) |
| 571 | endif() |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 572 | endif() |
| 573 | endfunction() |
Petr Hosek | 789b7f0 | 2019-05-30 04:40:21 +0000 | [diff] [blame] | 574 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 575 | # Warning flags =============================================================== |
Louis Dionne | c78c0e0 | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 576 | function(cxx_add_warning_flags target) |
| 577 | target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 578 | target_add_compile_flags_if_supported(${target} PRIVATE -Wall -Wextra -W -Wwrite-strings |
| 579 | -Wno-unused-parameter -Wno-long-long |
| 580 | -Werror=return-type -Wextra-semi) |
| 581 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 582 | target_add_compile_flags_if_supported(${target} PRIVATE |
| 583 | -Wno-user-defined-literals |
| 584 | -Wno-covered-switch-default |
Logan Smith | 77e0e9e | 2020-07-22 17:44:52 -0700 | [diff] [blame] | 585 | -Wno-suggest-override |
Louis Dionne | c78c0e0 | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 586 | -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs |
| 587 | ) |
Eric Fiselier | 0c8011f | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 588 | if (LIBCXX_TARGETING_CLANG_CL) |
Louis Dionne | c78c0e0 | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 589 | target_add_compile_flags_if_supported(${target} PRIVATE |
Eric Fiselier | 0c8011f | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 590 | -Wno-c++98-compat |
Eric Fiselier | 5e0b8fc | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 591 | -Wno-c++98-compat-pedantic |
Eric Fiselier | 0c8011f | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 592 | -Wno-c++11-compat |
| 593 | -Wno-undef |
Eric Fiselier | 5e0b8fc | 2018-10-01 01:31:23 +0000 | [diff] [blame] | 594 | -Wno-reserved-id-macro |
| 595 | -Wno-gnu-include-next |
| 596 | -Wno-gcc-compat # For ignoring "'diagnose_if' is a clang extension" warnings |
Eric Fiselier | e60359e | 2018-10-01 01:47:23 +0000 | [diff] [blame] | 597 | -Wno-zero-as-null-pointer-constant # FIXME: Remove this and fix all occurrences. |
| 598 | -Wno-deprecated-dynamic-exception-spec # For auto_ptr |
| 599 | -Wno-sign-conversion |
| 600 | -Wno-old-style-cast |
| 601 | -Wno-deprecated # FIXME: Remove this and fix all occurrences. |
Eric Fiselier | 0b485f3 | 2018-10-01 01:59:37 +0000 | [diff] [blame] | 602 | -Wno-shift-sign-overflow # FIXME: Why do we need this with clang-cl but not clang? |
Eric Fiselier | 1f44fda | 2018-10-01 03:59:05 +0000 | [diff] [blame] | 603 | -Wno-double-promotion # FIXME: remove me |
Eric Fiselier | 0c8011f | 2018-10-01 01:15:50 +0000 | [diff] [blame] | 604 | ) |
| 605 | endif() |
Louis Dionne | c78c0e0 | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 606 | elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") |
| 607 | target_add_compile_flags_if_supported(${target} PRIVATE |
| 608 | -Wno-literal-suffix |
| 609 | -Wno-c++14-compat |
Logan Smith | 77e0e9e | 2020-07-22 17:44:52 -0700 | [diff] [blame] | 610 | -Wno-noexcept-type |
| 611 | -Wno-suggest-override) |
Louis Dionne | c78c0e0 | 2019-10-02 19:31:30 +0000 | [diff] [blame] | 612 | endif() |
| 613 | if (LIBCXX_ENABLE_WERROR) |
| 614 | target_add_compile_flags_if_supported(${target} PRIVATE -Werror) |
| 615 | target_add_compile_flags_if_supported(${target} PRIVATE -WX) |
| 616 | else() |
| 617 | # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is |
| 618 | # added elsewhere. |
| 619 | target_add_compile_flags_if_supported(${target} PRIVATE -Wno-error) |
| 620 | endif() |
| 621 | if (LIBCXX_ENABLE_PEDANTIC) |
| 622 | target_add_compile_flags_if_supported(${target} PRIVATE -pedantic) |
| 623 | endif() |
| 624 | if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 625 | target_compile_definitions(${target} PRIVATE -D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 626 | endif() |
| 627 | endfunction() |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 628 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 629 | # Exception flags ============================================================= |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 630 | function(cxx_add_exception_flags target) |
| 631 | if (LIBCXX_ENABLE_EXCEPTIONS) |
| 632 | # Catches C++ exceptions only and tells the compiler to assume that extern C |
| 633 | # functions never throw a C++ exception. |
| 634 | target_add_compile_flags_if_supported(${target} PUBLIC -EHsc) |
| 635 | else() |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 636 | target_add_compile_flags_if_supported(${target} PUBLIC -EHs- -EHa-) |
| 637 | target_add_compile_flags_if_supported(${target} PUBLIC -fno-exceptions) |
| 638 | endif() |
| 639 | endfunction() |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 640 | |
| 641 | # RTTI flags ================================================================== |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 642 | function(cxx_add_rtti_flags target) |
| 643 | if (NOT LIBCXX_ENABLE_RTTI) |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 644 | target_add_compile_flags_if_supported(${target} PUBLIC -GR-) |
| 645 | target_add_compile_flags_if_supported(${target} PUBLIC -fno-rtti) |
| 646 | endif() |
| 647 | endfunction() |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 648 | |
Asiri Rathnayake | 8c2bf45 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 649 | # Threading flags ============================================================= |
Asiri Rathnayake | b71c899 | 2017-01-09 10:38:56 +0000 | [diff] [blame] | 650 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) |
Asiri Rathnayake | 8c2bf45 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 651 | # Need to allow unresolved symbols if this is to work with shared library builds |
| 652 | if (APPLE) |
| 653 | add_link_flags("-undefined dynamic_lookup") |
| 654 | else() |
| 655 | # Relax this restriction from HandleLLVMOptions |
| 656 | string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") |
| 657 | endif() |
| 658 | endif() |
| 659 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 660 | # Assertion flags ============================================================= |
| 661 | define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) |
| 662 | define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) |
Eric Fiselier | e49cdfb | 2017-02-04 23:22:28 +0000 | [diff] [blame] | 663 | define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) |
Eric Fiselier | 7e3ee09 | 2017-01-14 07:54:39 +0000 | [diff] [blame] | 664 | define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) |
| 665 | if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 666 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
Eric Fiselier | cc1f65c | 2017-01-14 06:06:47 +0000 | [diff] [blame] | 667 | define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) |
Howard Hinnant | a9f6980 | 2013-02-25 15:50:36 +0000 | [diff] [blame] | 668 | endif() |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 669 | |
Eric Fiselier | 194e027 | 2016-10-14 12:56:52 +0000 | [diff] [blame] | 670 | # Modules flags =============================================================== |
| 671 | # FIXME The libc++ sources are fundamentally non-modular. They need special |
| 672 | # versions of the headers in order to provide C++03 and legacy ABI definitions. |
| 673 | # NOTE: The public headers can be used with modules in all other contexts. |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 674 | function(cxx_add_module_flags target) |
| 675 | if (LLVM_ENABLE_MODULES) |
| 676 | # Ignore that the rest of the modules flags are now unused. |
Louis Dionne | 13c4254 | 2019-10-04 19:10:56 +0000 | [diff] [blame] | 677 | target_add_compile_flags_if_supported(${target} PUBLIC -Wno-unused-command-line-argument) |
| 678 | target_compile_options(${target} PUBLIC -fno-modules) |
Louis Dionne | 432ae75 | 2019-10-04 18:03:17 +0000 | [diff] [blame] | 679 | endif() |
| 680 | endfunction() |
Eric Fiselier | 194e027 | 2016-10-14 12:56:52 +0000 | [diff] [blame] | 681 | |
Jonathan Roelofs | 91b3a5e | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 682 | # Sanitizer flags ============================================================= |
Eric Fiselier | b98aa43 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 683 | |
Eric Fiselier | 02f8e7c35 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 684 | function(get_sanitizer_flags OUT_VAR USE_SANITIZER) |
| 685 | set(SANITIZER_FLAGS) |
| 686 | set(USE_SANITIZER "${USE_SANITIZER}") |
| 687 | # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. |
| 688 | # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. |
| 689 | if (USE_SANITIZER AND NOT MSVC) |
| 690 | append_flags_if_supported(SANITIZER_FLAGS "-fno-omit-frame-pointer") |
| 691 | append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") |
| 692 | |
| 693 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND |
| 694 | NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") |
| 695 | append_flags_if_supported(SANITIZER_FLAGS "-gline-tables-only") |
| 696 | endif() |
| 697 | if (USE_SANITIZER STREQUAL "Address") |
| 698 | append_flags(SANITIZER_FLAGS "-fsanitize=address") |
| 699 | elseif (USE_SANITIZER MATCHES "Memory(WithOrigins)?") |
| 700 | append_flags(SANITIZER_FLAGS -fsanitize=memory) |
| 701 | if (USE_SANITIZER STREQUAL "MemoryWithOrigins") |
| 702 | append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins") |
| 703 | endif() |
| 704 | elseif (USE_SANITIZER STREQUAL "Undefined") |
| 705 | append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Brian Gesiak | 54176d1 | 2020-04-04 13:01:32 -0400 | [diff] [blame] | 706 | elseif (USE_SANITIZER STREQUAL "Address;Undefined" OR |
| 707 | USE_SANITIZER STREQUAL "Undefined;Address") |
| 708 | append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Eric Fiselier | 02f8e7c35 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 709 | elseif (USE_SANITIZER STREQUAL "Thread") |
| 710 | append_flags(SANITIZER_FLAGS -fsanitize=thread) |
Zola Bridges | 0f12480 | 2020-04-17 10:15:58 -0700 | [diff] [blame] | 711 | elseif (USE_SANITIZER STREQUAL "DataFlow") |
| 712 | append_flags(SANITIZER_FLAGS -fsanitize=dataflow) |
Eric Fiselier | 02f8e7c35 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 713 | else() |
| 714 | message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${USE_SANITIZER}") |
| 715 | endif() |
| 716 | elseif(USE_SANITIZER AND MSVC) |
| 717 | message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") |
| 718 | endif() |
| 719 | set(${OUT_VAR} "${SANITIZER_FLAGS}" PARENT_SCOPE) |
| 720 | endfunction() |
| 721 | |
Chris Bieneman | 12b134b | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 722 | # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do |
Eric Fiselier | b98aa43 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 723 | # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. |
Chris Bieneman | 12b134b | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 724 | if (LIBCXX_STANDALONE_BUILD) |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 725 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 726 | "Define the sanitizer used to build the library and tests") |
Eric Fiselier | 02f8e7c35 | 2018-11-13 23:08:31 +0000 | [diff] [blame] | 727 | endif() |
| 728 | get_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}") |
| 729 | if (LIBCXX_STANDALONE_BUILD AND SANITIZER_FLAGS) |
| 730 | add_flags(${SANITIZER_FLAGS}) |
Eric Fiselier | b98aa43 | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 731 | endif() |
Eric Fiselier | f9f796e | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 732 | |
Louis Dionne | 3230087 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 733 | # Link system libraries ======================================================= |
| 734 | function(cxx_link_system_libraries target) |
| 735 | target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") |
| 736 | target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") |
| 737 | target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") |
| 738 | |
| 739 | if (LIBCXX_HAS_SYSTEM_LIB) |
| 740 | target_link_libraries(${target} PRIVATE System) |
| 741 | endif() |
| 742 | |
| 743 | if (LIBCXX_HAS_PTHREAD_LIB) |
| 744 | target_link_libraries(${target} PRIVATE pthread) |
| 745 | endif() |
| 746 | |
| 747 | if (LIBCXX_HAS_C_LIB) |
| 748 | target_link_libraries(${target} PRIVATE c) |
| 749 | endif() |
| 750 | |
| 751 | if (LIBCXX_HAS_M_LIB) |
| 752 | target_link_libraries(${target} PRIVATE m) |
| 753 | endif() |
| 754 | |
| 755 | if (LIBCXX_HAS_RT_LIB) |
| 756 | target_link_libraries(${target} PRIVATE rt) |
| 757 | endif() |
| 758 | |
| 759 | if (LIBCXX_USE_COMPILER_RT) |
| 760 | find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) |
| 761 | if (LIBCXX_BUILTINS_LIBRARY) |
| 762 | target_link_libraries(${target} PRIVATE "${LIBCXX_BUILTINS_LIBRARY}") |
| 763 | endif() |
Shoaib Meenai | cc25963 | 2020-04-23 21:19:11 -0700 | [diff] [blame] | 764 | elseif (LIBCXX_HAS_GCC_LIB) |
| 765 | target_link_libraries(${target} PRIVATE gcc) |
Louis Dionne | 3230087 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 766 | elseif (LIBCXX_HAS_GCC_S_LIB) |
| 767 | target_link_libraries(${target} PRIVATE gcc_s) |
| 768 | endif() |
| 769 | |
Louis Dionne | e018435 | 2020-06-04 14:54:38 -0400 | [diff] [blame] | 770 | if (LIBCXX_HAS_ATOMIC_LIB) |
Louis Dionne | 3230087 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 771 | target_link_libraries(${target} PRIVATE atomic) |
| 772 | endif() |
| 773 | |
| 774 | if (MINGW) |
| 775 | target_link_libraries(${target} PRIVATE "${MINGW_LIBRARIES}") |
| 776 | endif() |
| 777 | |
| 778 | if (LIBCXX_TARGETING_MSVC) |
| 779 | if (LIBCXX_DEBUG_BUILD) |
| 780 | set(LIB_SUFFIX "d") |
| 781 | else() |
| 782 | set(LIB_SUFFIX "") |
| 783 | endif() |
| 784 | |
| 785 | target_link_libraries(${target} PRIVATE ucrt${LIB_SUFFIX}) # Universal C runtime |
| 786 | target_link_libraries(${target} PRIVATE vcruntime${LIB_SUFFIX}) # C++ runtime |
| 787 | target_link_libraries(${target} PRIVATE msvcrt${LIB_SUFFIX}) # C runtime startup files |
| 788 | target_link_libraries(${target} PRIVATE msvcprt${LIB_SUFFIX}) # C++ standard library. Required for exception_ptr internals. |
| 789 | # Required for standards-complaint wide character formatting functions |
| 790 | # (e.g. `printfw`/`scanfw`) |
| 791 | target_link_libraries(${target} PRIVATE iso_stdio_wide_specifiers) |
| 792 | endif() |
Shoaib Meenai | 076da52 | 2020-01-27 17:29:41 -0800 | [diff] [blame] | 793 | |
| 794 | if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21) |
| 795 | target_link_libraries(${target} PUBLIC android_support) |
| 796 | endif() |
Louis Dionne | 3230087 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 797 | endfunction() |
| 798 | |
Louis Dionne | 925d9d2 | 2019-10-02 20:07:01 +0000 | [diff] [blame] | 799 | # Windows-related flags ======================================================= |
| 800 | function(cxx_add_windows_flags target) |
| 801 | if(WIN32 AND NOT MINGW) |
| 802 | target_compile_definitions(${target} PRIVATE |
| 803 | # Ignore the -MSC_VER mismatch, as we may build |
| 804 | # with a different compatibility version. |
| 805 | _ALLOW_MSC_VER_MISMATCH |
| 806 | # Don't check the msvcprt iterator debug levels |
| 807 | # as we will define the iterator types; libc++ |
| 808 | # uses a different macro to identify the debug |
| 809 | # level. |
| 810 | _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH |
| 811 | # We are building the c++ runtime, don't pull in |
| 812 | # msvcprt. |
| 813 | _CRTBLD |
| 814 | # Don't warn on the use of "deprecated" |
| 815 | # "insecure" functions which are standards |
| 816 | # specified. |
| 817 | _CRT_SECURE_NO_WARNINGS |
| 818 | # Use the ISO conforming behaviour for conversion |
| 819 | # in printf, scanf. |
| 820 | _CRT_STDIO_ISO_WIDE_SPECIFIERS) |
| 821 | endif() |
| 822 | endfunction() |
| 823 | |
Eric Fiselier | f9f796e | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 824 | # Configuration file flags ===================================================== |
Louis Dionne | f9a5290 | 2018-09-26 08:24:51 +0000 | [diff] [blame] | 825 | if (NOT LIBCXX_ABI_VERSION EQUAL 1) |
Evgeniy Stepanov | a66a7b3 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 826 | config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) |
| 827 | endif() |
Eric Fiselier | fe13c13 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 828 | if (NOT LIBCXX_ABI_NAMESPACE STREQUAL "") |
| 829 | if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*") |
Louis Dionne | 3c9063f | 2019-10-24 14:16:37 -0700 | [diff] [blame] | 830 | message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier.") |
Eric Fiselier | fe13c13 | 2018-10-30 21:44:53 +0000 | [diff] [blame] | 831 | endif() |
| 832 | if (LIBCXX_ABI_NAMESPACE MATCHES "__[0-9]+$") |
| 833 | message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE '${LIBCXX_ABI_NAMESPACE}' is reserved for use by libc++.") |
| 834 | endif() |
| 835 | config_define(${LIBCXX_ABI_NAMESPACE} _LIBCPP_ABI_NAMESPACE) |
| 836 | endif() |
Evgeniy Stepanov | a66a7b3 | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 837 | config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) |
Shoaib Meenai | a4a3d40 | 2017-10-05 02:18:08 +0000 | [diff] [blame] | 838 | config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM) |
| 839 | config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT) |
Louis Dionne | 61cd687 | 2018-08-16 12:44:28 +0000 | [diff] [blame] | 840 | config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT) |
Eric Fiselier | f9f796e | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 841 | config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) |
| 842 | config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) |
| 843 | config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) |
| 844 | config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) |
| 845 | config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) |
| 846 | config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) |
Louis Dionne | be00e88 | 2020-11-16 18:13:43 -0500 | [diff] [blame^] | 847 | if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default") |
Louis Dionne | d0fcdcd | 2020-05-15 15:58:19 -0400 | [diff] [blame] | 848 | config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION) |
Eric Fiselier | 2405bd6 | 2019-05-29 02:21:37 +0000 | [diff] [blame] | 849 | endif() |
Ben Craig | b9599b1 | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 850 | config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) |
Asiri Rathnayake | 8c2bf45 | 2016-09-11 21:46:40 +0000 | [diff] [blame] | 851 | config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) |
Martin Storsjo | bf02a09 | 2018-01-05 20:48:29 +0000 | [diff] [blame] | 852 | config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32) |
Eric Fiselier | 00f6bea | 2017-01-06 20:05:40 +0000 | [diff] [blame] | 853 | config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) |
Vasileios Kalintiris | 8c58e92 | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 854 | config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) |
Shoaib Meenai | 492d713 | 2017-10-09 19:25:17 +0000 | [diff] [blame] | 855 | config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) |
Louis Dionne | 0a06eb9 | 2019-08-05 18:29:14 +0000 | [diff] [blame] | 856 | config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITHMS) |
Louis Dionne | e0d0129 | 2020-10-15 10:32:09 -0400 | [diff] [blame] | 857 | config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE) |
Louis Dionne | 88ffc72 | 2020-10-09 15:31:05 -0400 | [diff] [blame] | 858 | config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION) |
Louis Dionne | 2eadbc8 | 2020-11-04 15:01:25 -0500 | [diff] [blame] | 859 | config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) |
Vasileios Kalintiris | 8c58e92 | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 860 | |
Shoaib Meenai | 8e62812 | 2017-10-04 23:17:12 +0000 | [diff] [blame] | 861 | if (LIBCXX_ABI_DEFINES) |
| 862 | set(abi_defines) |
| 863 | foreach (abi_define ${LIBCXX_ABI_DEFINES}) |
| 864 | if (NOT abi_define MATCHES "^_LIBCPP_ABI_") |
| 865 | message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES") |
| 866 | endif() |
| 867 | list(APPEND abi_defines "#define ${abi_define}") |
| 868 | endforeach() |
| 869 | string(REPLACE ";" "\n" abi_defines "${abi_defines}") |
| 870 | config_define(${abi_defines} _LIBCPP_ABI_DEFINES) |
| 871 | endif() |
| 872 | |
Eric Fiselier | 5464421 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 873 | # By default libc++ on Windows expects to use a shared library, which requires |
| 874 | # the headers to use DLL import/export semantics. However when building a |
| 875 | # static library only we modify the headers to disable DLL import/export. |
| 876 | if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) |
| 877 | message(STATUS "Generating custom __config for non-DLL Windows build") |
Shoaib Meenai | fc6100c | 2016-12-05 19:40:12 +0000 | [diff] [blame] | 878 | config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) |
Eric Fiselier | 5464421 | 2016-09-26 22:19:41 +0000 | [diff] [blame] | 879 | endif() |
| 880 | |
Martin Storsjö | 8a73aa8 | 2020-10-23 10:54:02 +0300 | [diff] [blame] | 881 | if (WIN32 AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
| 882 | # If linking libcxxabi statically into libcxx, skip the dllimport attributes |
| 883 | # on symbols we refer to from libcxxabi. |
| 884 | add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) |
| 885 | endif() |
| 886 | |
Louis Dionne | fadc84a | 2019-10-04 22:50:23 +0000 | [diff] [blame] | 887 | # Setup all common build flags ================================================= |
| 888 | function(cxx_add_common_build_flags target) |
| 889 | cxx_add_basic_build_flags(${target}) |
| 890 | cxx_add_warning_flags(${target}) |
| 891 | cxx_add_windows_flags(${target}) |
Louis Dionne | fadc84a | 2019-10-04 22:50:23 +0000 | [diff] [blame] | 892 | cxx_add_exception_flags(${target}) |
| 893 | cxx_add_rtti_flags(${target}) |
| 894 | cxx_add_module_flags(${target}) |
Louis Dionne | 3230087 | 2019-10-08 16:26:24 +0000 | [diff] [blame] | 895 | cxx_link_system_libraries(${target}) |
Louis Dionne | fadc84a | 2019-10-04 22:50:23 +0000 | [diff] [blame] | 896 | endfunction() |
| 897 | |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 898 | #=============================================================================== |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 899 | # Setup Source Code And Tests |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 900 | #=============================================================================== |
Howard Hinnant | 6a0d6ce | 2013-11-15 17:18:57 +0000 | [diff] [blame] | 901 | add_subdirectory(include) |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 +0000 | [diff] [blame] | 902 | add_subdirectory(src) |
Eric Fiselier | b17bb06 | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 903 | |
Eric Fiselier | 336a1a6 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 904 | set(LIBCXX_TEST_DEPS "") |
| 905 | |
| 906 | if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
| 907 | list(APPEND LIBCXX_TEST_DEPS cxx_experimental) |
| 908 | endif() |
Eric Fiselier | 336a1a6 | 2018-11-14 20:38:46 +0000 | [diff] [blame] | 909 | |
| 910 | if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) |
| 911 | list(APPEND LIBCXX_TEST_DEPS cxx_external_threads) |
| 912 | endif() |
Eric Fiselier | 28349f9 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 913 | |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 914 | if (LIBCXX_INCLUDE_BENCHMARKS) |
| 915 | add_subdirectory(benchmarks) |
| 916 | endif() |
Eric Fiselier | d94189d | 2017-03-01 21:53:30 +0000 | [diff] [blame] | 917 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 918 | if (LIBCXX_INCLUDE_TESTS) |
Louis Dionne | eb68a0a | 2020-06-29 11:51:15 -0400 | [diff] [blame] | 919 | add_subdirectory(test) |
Eric Fiselier | 28349f9 | 2016-11-14 02:43:12 +0000 | [diff] [blame] | 920 | add_subdirectory(lib/abi) |
Louis Dionne | eb68a0a | 2020-06-29 11:51:15 -0400 | [diff] [blame] | 921 | if (LIBCXX_STANDALONE_BUILD) |
| 922 | include(AddLLVM) # for get_llvm_lit_path |
| 923 | # Make sure the llvm-lit script is generated into the bin directory, and |
| 924 | # do it after adding all tests, since the generated script will only work |
| 925 | # correctly discovered tests against test locations from the source tree |
| 926 | # that have already been discovered. |
| 927 | add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit |
| 928 | ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) |
| 929 | endif() |
Zachary Turner | 50105d2 | 2017-09-19 17:19:10 +0000 | [diff] [blame] | 930 | endif() |
| 931 | |
Eric Fiselier | b17bb06 | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 932 | if (LIBCXX_INCLUDE_DOCS) |
| 933 | add_subdirectory(docs) |
| 934 | endif() |