Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 1 | # See www/CMake.html for instructions on how to build libcxx with CMake. |
| 2 | |
| 3 | #=============================================================================== |
| 4 | # Setup Project |
| 5 | #=============================================================================== |
Chris Bieneman | e490006 | 2016-05-31 20:21:52 +0000 | [diff] [blame] | 6 | cmake_minimum_required(VERSION 3.4.3) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 7 | |
Eric Fiselier | 9af31a4 | 2015-01-26 21:56:45 +0000 | [diff] [blame] | 8 | if(POLICY CMP0042) |
| 9 | cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default |
| 10 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 11 | if(POLICY CMP0022) |
| 12 | cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang |
| 13 | endif() |
| 14 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 15 | # Add path for custom modules |
| 16 | set(CMAKE_MODULE_PATH |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 17 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 18 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" |
Eric Fiselier | 0f932cb | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 19 | ${CMAKE_MODULE_PATH} |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 20 | ) |
| 21 | |
Eric Fiselier | 0f932cb | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 22 | # Find the LLVM sources and simulate LLVM CMake options. |
| 23 | include(HandleOutOfTreeLLVM) |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 24 | |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 25 | if (LIBCXX_STANDALONE_BUILD) |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 26 | project(libcxx CXX C) |
| 27 | |
| 28 | set(PACKAGE_NAME libcxx) |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 29 | set(PACKAGE_VERSION 4.0.0svn) |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 30 | set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") |
| 31 | set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 32 | endif() |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 33 | |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 34 | if (LIBCXX_STANDALONE_BUILD AND NOT LLVM_FOUND) |
Eric Fiselier | 0f932cb | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 35 | message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: " |
| 36 | "llvm-config not found and LLVM_PATH not defined.\n" |
Eric Fiselier | bd40283 | 2016-08-28 18:33:08 +0000 | [diff] [blame] | 37 | "Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config " |
Eric Fiselier | 0f932cb | 2015-12-30 03:39:03 +0000 | [diff] [blame] | 38 | "or -DLLVM_PATH=path/to/llvm-source-root.") |
| 39 | endif() |
| 40 | |
Saleem Abdulrasool | 115c9a9 | 2016-02-08 03:50:18 +0000 | [diff] [blame] | 41 | # Require out of source build. |
| 42 | include(MacroEnsureOutOfSourceBuild) |
| 43 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( |
| 44 | "${PROJECT_NAME} requires an out of source build. Please create a separate |
| 45 | build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." |
| 46 | ) |
| 47 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 48 | #=============================================================================== |
| 49 | # Setup CMake Options |
| 50 | #=============================================================================== |
Eric Fiselier | 121594e | 2016-09-07 01:15:10 +0000 | [diff] [blame^] | 51 | include(CMakeDependentOption) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 52 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 53 | # Basic options --------------------------------------------------------------- |
| 54 | option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) |
| 55 | option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) |
Petr Hosek | 1362005 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 56 | option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) |
Eric Fiselier | 35950a5 | 2016-05-03 21:30:18 +0000 | [diff] [blame] | 57 | option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) |
Eric Fiselier | 435db15 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 58 | option(LIBCXX_ENABLE_FILESYSTEM |
| 59 | "Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 60 | option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) |
Eric Fiselier | 93f212c | 2016-08-29 19:50:49 +0000 | [diff] [blame] | 61 | option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON) |
Eric Fiselier | 9e3e137 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 62 | option(LIBCXX_BUILD_BENCHMARK_NATIVE_STDLIB "Build the benchmarks against the native STL" OFF) |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 63 | option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 64 | set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING |
| 65 | "Define suffix of library directory name (32/64)") |
| 66 | option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) |
Eric Fiselier | 68205ee | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 67 | option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 68 | option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) |
Eric Fiselier | 121594e | 2016-09-07 01:15:10 +0000 | [diff] [blame^] | 69 | cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY |
| 70 | "Install libc++experimental.a" ON |
| 71 | "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) |
Evgeniy Stepanov | da2ff7e | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 72 | set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.") |
| 73 | option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) |
Saleem Abdulrasool | bac3482 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 74 | option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 75 | |
Petr Hosek | 1362005 | 2016-08-08 22:57:25 +0000 | [diff] [blame] | 76 | if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC) |
| 77 | message(FATAL_ERROR "libc++ must be built as either a shared or static library.") |
| 78 | endif() |
| 79 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 80 | # ABI Library options --------------------------------------------------------- |
| 81 | set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING |
| 82 | "Specify C++ ABI library to use." FORCE) |
| 83 | set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) |
| 84 | set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) |
| 85 | |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 86 | # Setup the default options if LIBCXX_CXX_ABI is not specified. |
| 87 | if (NOT LIBCXX_CXX_ABI) |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 88 | if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 89 | IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") |
| 90 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
| 91 | set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") |
| 92 | set(LIBCXX_CXX_ABI_INTREE 1) |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 93 | else() |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 94 | set(LIBCXX_CXX_ABI_LIBNAME "none") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 95 | endif() |
| 96 | else() |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 97 | set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") |
Eugene Zelenko | 0004c5b | 2016-08-08 18:01:50 +0000 | [diff] [blame] | 98 | endif() |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 99 | |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 100 | # Use a static copy of the ABI library when linking libc++. This option |
| 101 | # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 102 | option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) |
| 103 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 104 | # Generate and install a linker script inplace of libc++.so. The linker script |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 105 | # will link libc++ to the correct ABI library. This option is on by default |
| 106 | # On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' |
Eric Fiselier | ea5fc6c | 2015-10-22 20:50:07 +0000 | [diff] [blame] | 107 | # is on. This option is also disabled when the ABI library is not specified |
| 108 | # or is specified to be "none". |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 109 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) |
Eric Fiselier | 16a3c82 | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 110 | if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY |
Eric Fiselier | 10cb09b | 2015-10-22 20:54:27 +0000 | [diff] [blame] | 111 | AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" |
Asiri Rathnayake | 4fa5b8c | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 112 | AND PYTHONINTERP_FOUND |
| 113 | AND LIBCXX_ENABLE_SHARED) |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 114 | set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) |
| 115 | endif() |
| 116 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 117 | option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT |
Eric Fiselier | 0b09dd1 | 2015-10-15 22:41:51 +0000 | [diff] [blame] | 118 | "Use and install a linker script for the given ABI library" |
Eric Fiselier | 16a3c82 | 2015-10-15 23:04:54 +0000 | [diff] [blame] | 119 | ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 120 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 121 | # Build libc++abi with libunwind. We need this option to determine whether to |
| 122 | # link with libunwind or libgcc_s while running the test cases. |
| 123 | option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) |
| 124 | |
| 125 | # Target options -------------------------------------------------------------- |
| 126 | option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) |
| 127 | set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") |
| 128 | set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") |
| 129 | |
| 130 | # Feature options ------------------------------------------------------------- |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 131 | option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) |
| 132 | option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) |
Ed Schouten | 7009f4e | 2015-03-12 15:44:39 +0000 | [diff] [blame] | 133 | option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) |
Ed Schouten | 3a75c0b | 2015-03-26 14:35:46 +0000 | [diff] [blame] | 134 | option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) |
| 135 | option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) |
Eric Fiselier | 5b9755b | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 136 | option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) |
Ed Schouten | 137c863 | 2015-06-24 08:44:38 +0000 | [diff] [blame] | 137 | option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) |
Eric Fiselier | 5b9755b | 2014-12-06 21:02:58 +0000 | [diff] [blame] | 138 | option(LIBCXX_ENABLE_MONOTONIC_CLOCK |
| 139 | "Build libc++ with support for a monotonic clock. |
Jonathan Roelofs | b6a8286 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 140 | This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 141 | option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 142 | option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 143 | |
| 144 | # Misc options ---------------------------------------------------------------- |
Eric Fiselier | 62b5097 | 2015-10-10 03:34:52 +0000 | [diff] [blame] | 145 | # FIXME: Turn -pedantic back ON. It is currently off because it warns |
| 146 | # about #include_next which is used everywhere. |
| 147 | option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 148 | option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) |
Saleem Abdulrasool | be06cfe | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 149 | option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 150 | |
Eric Fiselier | bcd5d26 | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 151 | option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) |
| 152 | set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 153 | "The Profile-rt library used to build with code coverage") |
| 154 | |
Eric Fiselier | 68205ee | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 155 | # Don't allow a user to accidentally overwrite the system libc++ installation on Darwin. |
| 156 | # If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++ |
| 157 | # will not be generated and a warning will be issued. |
| 158 | option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF) |
| 159 | mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default. |
| 160 | |
| 161 | if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL) |
| 162 | if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") |
| 163 | message(WARNING "Disabling libc++ install rules because installation would " |
| 164 | "overwrite the systems installation. Configure with " |
| 165 | "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.") |
| 166 | mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option. |
| 167 | set(LIBCXX_INSTALL_HEADERS OFF) |
| 168 | set(LIBCXX_INSTALL_LIBRARY OFF) |
| 169 | endif() |
| 170 | endif() |
| 171 | |
Eric Fiselier | 884539e | 2015-12-16 23:41:05 +0000 | [diff] [blame] | 172 | set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) |
| 173 | if (XCODE OR MSVC_IDE) |
| 174 | set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) |
| 175 | endif() |
| 176 | option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" |
| 177 | ${LIBCXX_CONFIGURE_IDE_DEFAULT}) |
| 178 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 179 | #=============================================================================== |
| 180 | # Check option configurations |
| 181 | #=============================================================================== |
| 182 | |
Eric Fiselier | 435db15 | 2016-06-17 19:46:40 +0000 | [diff] [blame] | 183 | if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) |
| 184 | message(FATAL_ERROR |
| 185 | "LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF") |
| 186 | endif() |
| 187 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 188 | # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when |
| 189 | # LIBCXX_ENABLE_THREADS is on. |
| 190 | if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) |
| 191 | message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" |
| 192 | " when LIBCXX_ENABLE_THREADS is also set to OFF.") |
Eric Fiselier | 2ff6e5a | 2014-08-18 05:03:46 +0000 | [diff] [blame] | 193 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 194 | |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 195 | if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) |
| 196 | message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" |
| 197 | " when LIBCXX_ENABLE_THREADS is also set to ON.") |
| 198 | endif() |
| 199 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 200 | # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE |
| 201 | # is ON. |
| 202 | if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) |
| 203 | message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") |
| 204 | endif() |
| 205 | |
| 206 | # Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) |
| 207 | # and check that we can build with 32 bits if requested. |
| 208 | if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) |
| 209 | if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM |
| 210 | message(STATUS "Building 32 bits executables and libraries.") |
| 211 | endif() |
| 212 | elseif(LIBCXX_BUILD_32_BITS) |
| 213 | message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") |
| 214 | endif() |
| 215 | |
| 216 | # Check that this option is not enabled on Apple and emit a usage warning. |
Eric Fiselier | 070ed9a | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 217 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
| 218 | if (APPLE) |
| 219 | message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") |
| 220 | else() |
| 221 | message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") |
| 222 | endif() |
| 223 | endif() |
| 224 | |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 225 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 226 | if (APPLE) |
| 227 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") |
| 228 | endif() |
| 229 | if (NOT PYTHONINTERP_FOUND) |
| 230 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.") |
| 231 | endif() |
Asiri Rathnayake | 4fa5b8c | 2016-05-14 23:58:11 +0000 | [diff] [blame] | 232 | if (NOT LIBCXX_ENABLE_SHARED) |
| 233 | message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") |
| 234 | endif() |
Eric Fiselier | 2c16786 | 2015-10-14 19:54:03 +0000 | [diff] [blame] | 235 | endif() |
| 236 | |
| 237 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 238 | message(FATAL_ERROR "Conflicting options given. |
| 239 | LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with |
| 240 | LIBCXX_ENABLE_ABI_LINKER_SCRIPT") |
| 241 | endif() |
| 242 | |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 243 | if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) |
| 244 | message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off" |
| 245 | "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") |
| 246 | endif() |
| 247 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 248 | #=============================================================================== |
| 249 | # Configure System |
| 250 | #=============================================================================== |
| 251 | |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 252 | set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) |
| 253 | set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 254 | set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
Chandler Carruth | ec54e10 | 2014-12-29 12:15:47 +0000 | [diff] [blame] | 255 | set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) |
Eric Fiselier | 26dcc93 | 2014-12-20 03:16:55 +0000 | [diff] [blame] | 256 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 257 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
| 258 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) |
| 259 | |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 260 | # Declare libc++ configuration variables. |
| 261 | # They are intended for use as follows: |
| 262 | # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. |
| 263 | # LIBCXX_COMPILE_FLAGS: Compile only flags. |
| 264 | # LIBCXX_LINK_FLAGS: Linker only flags. |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 265 | set(LIBCXX_COMPILE_FLAGS "") |
| 266 | set(LIBCXX_LINK_FLAGS "") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 267 | set(LIBCXX_LIBRARIES "") |
Eric Fiselier | 6a4f6ce | 2014-11-15 06:26:30 +0000 | [diff] [blame] | 268 | |
Eric Fiselier | 96addd3 | 2016-06-02 01:10:08 +0000 | [diff] [blame] | 269 | # Include macros for adding and removing libc++ flags. |
| 270 | include(HandleLibcxxFlags) |
| 271 | |
| 272 | # Target flags ================================================================ |
| 273 | # These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that |
| 274 | # 'config-ix' use them during feature checks. It also adds them to both |
| 275 | # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' |
| 276 | add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") |
| 277 | add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}") |
| 278 | add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}") |
| 279 | add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") |
| 280 | |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 281 | # Configure compiler. |
| 282 | include(config-ix) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 283 | |
Saleem Abdulrasool | bac3482 | 2016-08-24 04:22:52 +0000 | [diff] [blame] | 284 | if (LIBCXX_USE_COMPILER_RT) |
| 285 | list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt") |
| 286 | endif() |
| 287 | |
Eric Fiselier | bcd5d26 | 2015-03-31 04:15:45 +0000 | [diff] [blame] | 288 | # Configure coverage options. |
| 289 | if (LIBCXX_GENERATE_COVERAGE) |
| 290 | include(CodeCoverage) |
| 291 | set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) |
| 292 | endif() |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 293 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 294 | string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) |
| 295 | |
Eric Fiselier | d0e4e10 | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 296 | #=============================================================================== |
| 297 | # Setup Compiler Flags |
| 298 | #=============================================================================== |
| 299 | |
JF Bastien | bffc6cf | 2016-03-05 14:22:02 +0000 | [diff] [blame] | 300 | include(HandleLibCXXABI) # Setup the ABI library flags |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 301 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 302 | # Remove flags that may have snuck in. |
| 303 | remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG |
| 304 | -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32) |
| 305 | |
Eric Fiselier | 25426b9 | 2015-10-13 23:56:33 +0000 | [diff] [blame] | 306 | # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. |
Eric Fiselier | cadda54 | 2015-10-15 20:27:15 +0000 | [diff] [blame] | 307 | # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors |
| 308 | # so they don't get transformed into -Wno and -errors respectivly. |
| 309 | remove_flags(-Wno-pedantic -pedantic-errors -pedantic) |
Eric Fiselier | 25426b9 | 2015-10-13 23:56:33 +0000 | [diff] [blame] | 310 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 311 | # Required flags ============================================================== |
Eric Fiselier | 5c2da3f | 2016-08-14 22:51:54 +0000 | [diff] [blame] | 312 | set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect") |
| 313 | add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER}) |
| 314 | mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME) |
| 315 | if (NOT MSVC AND NOT ${SUPPORTS_DIALECT_NAME}) |
| 316 | message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 317 | endif() |
| 318 | |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 319 | # On all systems the system c++ standard library headers need to be excluded. |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 320 | # MSVC only has -X, which disables all default includes; including the crt. |
| 321 | # Thus, we do nothing and hope we don't accidentally include any of the C++ |
| 322 | # headers |
| 323 | add_compile_flags_if_supported(-nostdinc++) |
Eric Fiselier | 285e796 | 2015-07-29 21:07:28 +0000 | [diff] [blame] | 324 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 325 | # Warning flags =============================================================== |
Eric Fiselier | e012bf2 | 2015-07-18 20:40:46 +0000 | [diff] [blame] | 326 | add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 327 | add_compile_flags_if_supported( |
Eric Fiselier | f0d9d5d | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 328 | -Wall -Wextra -W -Wwrite-strings |
| 329 | -Wno-unused-parameter -Wno-long-long |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 330 | -Werror=return-type) |
Eric Fiselier | f0d9d5d | 2016-08-29 20:43:38 +0000 | [diff] [blame] | 331 | if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 332 | add_compile_flags_if_supported( |
| 333 | -Wno-user-defined-literals |
| 334 | -Wno-covered-switch-default) |
| 335 | elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") |
| 336 | add_compile_flags_if_supported( |
| 337 | -Wno-attributes # FIXME: Fix -Wattribute warnings. |
| 338 | -Wno-literal-suffix |
| 339 | -Wno-c++14-compat) |
| 340 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 341 | if (LIBCXX_ENABLE_WERROR) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 342 | add_compile_flags_if_supported(-Werror) |
| 343 | add_compile_flags_if_supported(-WX) |
Eric Fiselier | 4959dd9 | 2015-07-31 01:25:01 +0000 | [diff] [blame] | 344 | else() |
| 345 | # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is |
| 346 | # added elsewhere. |
| 347 | add_compile_flags_if_supported(-Wno-error) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 348 | endif() |
| 349 | if (LIBCXX_ENABLE_PEDANTIC) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 350 | add_compile_flags_if_supported(-pedantic) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 351 | endif() |
Saleem Abdulrasool | be06cfe | 2016-07-12 14:39:13 +0000 | [diff] [blame] | 352 | if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 353 | add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) |
| 354 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 355 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 356 | # Exception flags ============================================================= |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 357 | if (LIBCXX_ENABLE_EXCEPTIONS) |
| 358 | # Catches C++ exceptions only and tells the compiler to assume that extern C |
| 359 | # functions never throw a C++ exception. |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 360 | add_compile_flags_if_supported(-EHsc) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 361 | else() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 362 | add_definitions(-D_LIBCPP_NO_EXCEPTIONS) |
| 363 | add_compile_flags_if_supported(-EHs- -EHa-) |
| 364 | add_compile_flags_if_supported(-fno-exceptions) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 365 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 366 | |
| 367 | # RTTI flags ================================================================== |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 368 | if (NOT LIBCXX_ENABLE_RTTI) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 369 | add_definitions(-D_LIBCPP_NO_RTTI) |
| 370 | add_compile_flags_if_supported(-GR-) |
| 371 | add_compile_flags_if_supported(-fno-rtti) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 372 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 373 | |
| 374 | # Assertion flags ============================================================= |
| 375 | define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) |
| 376 | define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) |
Howard Hinnant | ec3bb02 | 2012-08-05 17:37:39 +0000 | [diff] [blame] | 377 | if (LIBCXX_ENABLE_ASSERTIONS) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 378 | # MSVC doesn't like _DEBUG on release builds. See PR 4379. |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 379 | define_if_not(MSVC -D_DEBUG) |
Howard Hinnant | 807d633 | 2013-02-25 15:50:36 +0000 | [diff] [blame] | 380 | endif() |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 381 | |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 382 | # Feature flags =============================================================== |
| 383 | define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 384 | |
Jonathan Roelofs | b6a8286 | 2015-08-24 21:20:07 +0000 | [diff] [blame] | 385 | # Sanitizer flags ============================================================= |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 386 | |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 387 | # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 388 | # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. |
Chris Bieneman | 6567d58 | 2016-08-18 21:31:51 +0000 | [diff] [blame] | 389 | if (LIBCXX_STANDALONE_BUILD) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 390 | set(LLVM_USE_SANITIZER "" CACHE STRING |
| 391 | "Define the sanitizer used to build the library and tests") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 392 | # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. |
| 393 | # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. |
| 394 | if (LLVM_USE_SANITIZER AND NOT MSVC) |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 395 | add_flags_if_supported("-fno-omit-frame-pointer") |
| 396 | add_flags_if_supported("-gline-tables-only") |
| 397 | |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 398 | if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND |
| 399 | NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 400 | add_flags_if_supported("-gline-tables-only") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 401 | endif() |
| 402 | if (LLVM_USE_SANITIZER STREQUAL "Address") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 403 | add_flags("-fsanitize=address") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 404 | elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 405 | add_flags(-fsanitize=memory) |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 406 | if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 407 | add_flags("-fsanitize-memory-track-origins") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 408 | endif() |
| 409 | elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 410 | add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 411 | elseif (LLVM_USE_SANITIZER STREQUAL "Thread") |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 412 | add_flags(-fsanitize=thread) |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 413 | else() |
| 414 | message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") |
| 415 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 416 | elseif(LLVM_USE_SANITIZER AND MSVC) |
| 417 | message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") |
Eric Fiselier | e50f82d | 2015-07-29 23:46:55 +0000 | [diff] [blame] | 418 | endif() |
| 419 | endif() |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 420 | |
| 421 | # Configuration file flags ===================================================== |
Evgeniy Stepanov | da2ff7e | 2015-10-13 23:48:28 +0000 | [diff] [blame] | 422 | if (NOT LIBCXX_ABI_VERSION EQUAL "1") |
| 423 | config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) |
| 424 | endif() |
| 425 | config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) |
| 426 | |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 427 | config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) |
| 428 | config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) |
| 429 | config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) |
| 430 | config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) |
| 431 | config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) |
| 432 | config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) |
| 433 | |
Ben Craig | 5593c4f | 2016-05-25 17:40:09 +0000 | [diff] [blame] | 434 | config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) |
Vasileios Kalintiris | 281b4cf | 2015-11-09 10:21:04 +0000 | [diff] [blame] | 435 | config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) |
| 436 | |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 437 | if (LIBCXX_NEEDS_SITE_CONFIG) |
| 438 | configure_file( |
| 439 | include/__config_site.in |
| 440 | ${LIBCXX_BINARY_DIR}/__config_site |
| 441 | @ONLY) |
Eric Fiselier | 1a1c74b | 2015-10-14 00:22:05 +0000 | [diff] [blame] | 442 | # Provide the config definitions by included the generated __config_site |
| 443 | # file at compile time. |
| 444 | add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") |
Eric Fiselier | 5cf9a82 | 2015-10-13 22:12:02 +0000 | [diff] [blame] | 445 | endif() |
| 446 | |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 447 | #=============================================================================== |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 448 | # Setup Source Code And Tests |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 449 | #=============================================================================== |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 450 | include_directories(include) |
Howard Hinnant | 6e207d5 | 2013-11-15 17:18:57 +0000 | [diff] [blame] | 451 | add_subdirectory(include) |
Michael J. Spencer | 8d8164e | 2010-12-10 19:47:54 +0000 | [diff] [blame] | 452 | add_subdirectory(lib) |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 453 | |
Eric Fiselier | 9e3e137 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 454 | if (LIBCXX_INCLUDE_BENCHMARKS) |
| 455 | add_subdirectory(benchmarks) |
| 456 | endif() |
Eric Fiselier | 156a46d | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 457 | if (LIBCXX_INCLUDE_TESTS) |
| 458 | add_subdirectory(test) |
| 459 | endif() |
Eric Fiselier | d720d1f | 2015-08-22 19:40:49 +0000 | [diff] [blame] | 460 | if (LIBCXX_INCLUDE_DOCS) |
| 461 | add_subdirectory(docs) |
| 462 | endif() |