blob: 11958d9baba12cc10958200be4d70c4a63f623ef [file] [log] [blame]
Michael J. Spencer8d8164e2010-12-10 19:47:54 +00001# See www/CMake.html for instructions on how to build libcxx with CMake.
2
3#===============================================================================
4# Setup Project
5#===============================================================================
Michael J. Spencer8d8164e2010-12-10 19:47:54 +00006cmake_minimum_required(VERSION 2.8)
7
Eric Fiselier9af31a42015-01-26 21:56:45 +00008if(POLICY CMP0042)
9 cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
10endif()
Eric Fiselier156a46d2015-07-30 22:30:34 +000011if(POLICY CMP0022)
12 cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
13endif()
14
15project(libcxx CXX C)
Eric Fiselier9af31a42015-01-26 21:56:45 +000016
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000017set(PACKAGE_NAME libcxx)
18set(PACKAGE_VERSION trunk-svn)
19set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
Tanya Lattnerd49d4f72015-08-05 03:59:14 +000020set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000021
22# Add path for custom modules
23set(CMAKE_MODULE_PATH
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000024 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
25 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
Alexey Samsonovea3ed972013-09-30 09:10:01 +000026 ${CMAKE_MODULE_PATH}
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000027 )
28
29# Require out of source build.
30include(MacroEnsureOutOfSourceBuild)
31MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
32 "${PROJECT_NAME} requires an out of source build. Please create a separate
33 build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
34 )
35
Eric Fiselier156a46d2015-07-30 22:30:34 +000036# Find the LLVM sources and simulate LLVM CMake options.
37include(HandleOutOfTreeLLVM)
38if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND)
39 message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
40 "llvm-config not found and LLVM_PATH not defined.\n"
41 "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
42 "or -DLLVM_PATH=path/to/llvm-source-root.")
Eric Fiseliere50f82d2015-07-29 23:46:55 +000043endif()
Peter Collingbourne68781422013-10-03 21:58:25 +000044
Eric Fiselier156a46d2015-07-30 22:30:34 +000045
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000046#===============================================================================
47# Setup CMake Options
48#===============================================================================
49
Eric Fiselier156a46d2015-07-30 22:30:34 +000050# Basic options ---------------------------------------------------------------
51option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
52option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
53
54option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
Eric Fiselierd720d1f2015-08-22 19:40:49 +000055option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
Eric Fiselier156a46d2015-07-30 22:30:34 +000056set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
57 "Define suffix of library directory name (32/64)")
58option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
Eric Fiselier68205ee2015-08-26 20:18:21 +000059option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
Eric Fiselier156a46d2015-07-30 22:30:34 +000060option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
Evgeniy Stepanovda2ff7e2015-10-13 23:48:28 +000061set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
62option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
Eric Fiselier156a46d2015-07-30 22:30:34 +000063
64# ABI Library options ---------------------------------------------------------
65set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
66 "Specify C++ ABI library to use." FORCE)
67set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
68set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
69
Eric Fiselier0b09dd12015-10-15 22:41:51 +000070# Use a static copy of the ABI library when linking libc++. This option
71# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT.
Eric Fiselier156a46d2015-07-30 22:30:34 +000072option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
73
Eric Fiselier2c167862015-10-14 19:54:03 +000074# Generate and install a linker script inplace of libc++.so. The linker script
Eric Fiselier0b09dd12015-10-15 22:41:51 +000075# will link libc++ to the correct ABI library. This option is on by default
76# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
77# is on.
78set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
79if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
80 set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
81endif()
82
Eric Fiselier2c167862015-10-14 19:54:03 +000083option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
Eric Fiselier0b09dd12015-10-15 22:41:51 +000084 "Use and install a linker script for the given ABI library"
85 ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
Eric Fiselier2c167862015-10-14 19:54:03 +000086
Eric Fiselier156a46d2015-07-30 22:30:34 +000087# Build libc++abi with libunwind. We need this option to determine whether to
88# link with libunwind or libgcc_s while running the test cases.
89option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
90
91# Target options --------------------------------------------------------------
92option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
93set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
94set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
95
96# Feature options -------------------------------------------------------------
Michael J. Spencer8d8164e2010-12-10 19:47:54 +000097option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
98option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
Ed Schouten7009f4e2015-03-12 15:44:39 +000099option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
Ed Schouten3a75c0b2015-03-26 14:35:46 +0000100option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
101option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
Eric Fiselier5b9755b2014-12-06 21:02:58 +0000102option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
Ed Schouten137c8632015-06-24 08:44:38 +0000103option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
Eric Fiselier5b9755b2014-12-06 21:02:58 +0000104option(LIBCXX_ENABLE_MONOTONIC_CLOCK
105 "Build libc++ with support for a monotonic clock.
Jonathan Roelofsb6a82862015-08-24 21:20:07 +0000106 This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000107
108# Misc options ----------------------------------------------------------------
Eric Fiselier62b50972015-10-10 03:34:52 +0000109# FIXME: Turn -pedantic back ON. It is currently off because it warns
110# about #include_next which is used everywhere.
111option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000112option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
113
Eric Fiselierbcd5d262015-03-31 04:15:45 +0000114option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
115set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
Eric Fiselier156a46d2015-07-30 22:30:34 +0000116 "The Profile-rt library used to build with code coverage")
117
Eric Fiselier68205ee2015-08-26 20:18:21 +0000118# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin.
119# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++
120# will not be generated and a warning will be issued.
121option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF)
122mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default.
123
124if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL)
125 if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr")
126 message(WARNING "Disabling libc++ install rules because installation would "
127 "overwrite the systems installation. Configure with "
128 "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.")
129 mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option.
130 set(LIBCXX_INSTALL_HEADERS OFF)
131 set(LIBCXX_INSTALL_LIBRARY OFF)
132 endif()
133endif()
134
Eric Fiselier156a46d2015-07-30 22:30:34 +0000135#===============================================================================
136# Check option configurations
137#===============================================================================
138
139# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
140# LIBCXX_ENABLE_THREADS is on.
141if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
142 message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
143 " when LIBCXX_ENABLE_THREADS is also set to OFF.")
Eric Fiselier2ff6e5a2014-08-18 05:03:46 +0000144endif()
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000145
Eric Fiselier156a46d2015-07-30 22:30:34 +0000146# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
147# is ON.
148if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
149 message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
150endif()
151
152# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS)
153# and check that we can build with 32 bits if requested.
154if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
155 if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
156 message(STATUS "Building 32 bits executables and libraries.")
157 endif()
158elseif(LIBCXX_BUILD_32_BITS)
159 message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
160endif()
161
162# Check that this option is not enabled on Apple and emit a usage warning.
Eric Fiselier070ed9a2015-03-03 15:59:51 +0000163if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
164 if (APPLE)
165 message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
166 else()
167 message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
168 endif()
169endif()
170
Eric Fiselier2c167862015-10-14 19:54:03 +0000171if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
172 if (APPLE)
173 message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
174 endif()
175 if (NOT PYTHONINTERP_FOUND)
176 message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.")
177 endif()
178endif()
179
180if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
181 message(FATAL_ERROR "Conflicting options given.
182 LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with
183 LIBCXX_ENABLE_ABI_LINKER_SCRIPT")
184endif()
185
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000186#===============================================================================
187# Configure System
188#===============================================================================
189
Eric Fiselier26dcc932014-12-20 03:16:55 +0000190set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
191set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
192set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
Chandler Carruthec54e102014-12-29 12:15:47 +0000193set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
Eric Fiselier26dcc932014-12-20 03:16:55 +0000194
Eric Fiselier156a46d2015-07-30 22:30:34 +0000195set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
196set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
197
Eric Fiselier6a4f6ce2014-11-15 06:26:30 +0000198# Declare libc++ configuration variables.
199# They are intended for use as follows:
200# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
201# LIBCXX_COMPILE_FLAGS: Compile only flags.
202# LIBCXX_LINK_FLAGS: Linker only flags.
Eric Fiselier6a4f6ce2014-11-15 06:26:30 +0000203set(LIBCXX_COMPILE_FLAGS "")
204set(LIBCXX_LINK_FLAGS "")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000205set(LIBCXX_LIBRARIES "")
Eric Fiselier6a4f6ce2014-11-15 06:26:30 +0000206
Eric Fiselierd0e4e102014-11-15 17:25:23 +0000207# Configure compiler.
208include(config-ix)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000209
Eric Fiselierbcd5d262015-03-31 04:15:45 +0000210# Configure coverage options.
211if (LIBCXX_GENERATE_COVERAGE)
212 include(CodeCoverage)
213 set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
214endif()
Eric Fiselierd0e4e102014-11-15 17:25:23 +0000215
Eric Fiselier156a46d2015-07-30 22:30:34 +0000216string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
217
Eric Fiselierd0e4e102014-11-15 17:25:23 +0000218#===============================================================================
219# Setup Compiler Flags
220#===============================================================================
221
Eric Fiselier156a46d2015-07-30 22:30:34 +0000222include(HandleLibCXXABI) # Steup the ABI library flags
223
224# Include macros for adding and removing libc++ flags.
225include(HandleLibcxxFlags)
226
227# Remove flags that may have snuck in.
228remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
229 -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
230
Eric Fiselier25426b92015-10-13 23:56:33 +0000231# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
Eric Fiseliercadda542015-10-15 20:27:15 +0000232# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
233# so they don't get transformed into -Wno and -errors respectivly.
234remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
Eric Fiselier25426b92015-10-13 23:56:33 +0000235
Eric Fiselier156a46d2015-07-30 22:30:34 +0000236# Required flags ==============================================================
237add_compile_flags_if_supported(-std=c++11)
238if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG)
239 message(FATAL_ERROR "C++11 is required but the compiler does not support -std=c++11")
240endif()
241
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000242# On all systems the system c++ standard library headers need to be excluded.
Eric Fiselier156a46d2015-07-30 22:30:34 +0000243# MSVC only has -X, which disables all default includes; including the crt.
244# Thus, we do nothing and hope we don't accidentally include any of the C++
245# headers
246add_compile_flags_if_supported(-nostdinc++)
Eric Fiselier285e7962015-07-29 21:07:28 +0000247
Eric Fiselier156a46d2015-07-30 22:30:34 +0000248# Target flags ================================================================
249add_flags_if(LIBCXX_BUILD_32_BITS -m32)
250add_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
251add_flags_if(LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
252add_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
Eric Fiselier64473a12015-07-29 00:03:51 +0000253
Eric Fiselier156a46d2015-07-30 22:30:34 +0000254# Warning flags ===============================================================
Eric Fiseliere012bf22015-07-18 20:40:46 +0000255add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000256add_compile_flags_if_supported(
257 -Wall -W -Wwrite-strings
258 -Wno-unused-parameter -Wno-long-long
259 -Werror=return-type)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000260if (LIBCXX_ENABLE_WERROR)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000261 add_compile_flags_if_supported(-Werror)
262 add_compile_flags_if_supported(-WX)
Eric Fiselier4959dd92015-07-31 01:25:01 +0000263else()
264 # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
265 # added elsewhere.
266 add_compile_flags_if_supported(-Wno-error)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000267endif()
268if (LIBCXX_ENABLE_PEDANTIC)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000269 add_compile_flags_if_supported(-pedantic)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000270endif()
271
Eric Fiselier156a46d2015-07-30 22:30:34 +0000272# Exception flags =============================================================
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000273if (LIBCXX_ENABLE_EXCEPTIONS)
274 # Catches C++ exceptions only and tells the compiler to assume that extern C
275 # functions never throw a C++ exception.
Eric Fiselier156a46d2015-07-30 22:30:34 +0000276 add_compile_flags_if_supported(-EHsc)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000277else()
Eric Fiselier156a46d2015-07-30 22:30:34 +0000278 add_definitions(-D_LIBCPP_NO_EXCEPTIONS)
279 add_compile_flags_if_supported(-EHs- -EHa-)
280 add_compile_flags_if_supported(-fno-exceptions)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000281endif()
Eric Fiselier156a46d2015-07-30 22:30:34 +0000282
283# RTTI flags ==================================================================
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000284if (NOT LIBCXX_ENABLE_RTTI)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000285 add_definitions(-D_LIBCPP_NO_RTTI)
286 add_compile_flags_if_supported(-GR-)
287 add_compile_flags_if_supported(-fno-rtti)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000288endif()
Eric Fiselier156a46d2015-07-30 22:30:34 +0000289
290# Assertion flags =============================================================
291define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
292define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
Howard Hinnantec3bb022012-08-05 17:37:39 +0000293if (LIBCXX_ENABLE_ASSERTIONS)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000294 # MSVC doesn't like _DEBUG on release builds. See PR 4379.
Eric Fiselier156a46d2015-07-30 22:30:34 +0000295 define_if_not(MSVC -D_DEBUG)
Howard Hinnant807d6332013-02-25 15:50:36 +0000296endif()
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000297
Eric Fiselier156a46d2015-07-30 22:30:34 +0000298# Feature flags ===============================================================
299define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000300
Jonathan Roelofsb6a82862015-08-24 21:20:07 +0000301# Sanitizer flags =============================================================
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000302
303# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do
304# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
305if (LIBCXX_BUILT_STANDALONE)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000306 set(LLVM_USE_SANITIZER "" CACHE STRING
307 "Define the sanitizer used to build the library and tests")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000308 # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
309 # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
310 if (LLVM_USE_SANITIZER AND NOT MSVC)
Eric Fiselier156a46d2015-07-30 22:30:34 +0000311 add_flags_if_supported("-fno-omit-frame-pointer")
312 add_flags_if_supported("-gline-tables-only")
313
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000314 if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
315 NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000316 add_flags_if_supported("-gline-tables-only")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000317 endif()
318 if (LLVM_USE_SANITIZER STREQUAL "Address")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000319 add_flags("-fsanitize=address")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000320 elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000321 add_flags(-fsanitize=memory)
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000322 if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000323 add_flags("-fsanitize-memory-track-origins")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000324 endif()
325 elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000326 add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000327 elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
Eric Fiselier156a46d2015-07-30 22:30:34 +0000328 add_flags(-fsanitize=thread)
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000329 else()
330 message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
331 endif()
Eric Fiselier156a46d2015-07-30 22:30:34 +0000332 elseif(LLVM_USE_SANITIZER AND MSVC)
333 message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
Eric Fiseliere50f82d2015-07-29 23:46:55 +0000334 endif()
335endif()
Eric Fiselier5cf9a822015-10-13 22:12:02 +0000336
337# Configuration file flags =====================================================
Evgeniy Stepanovda2ff7e2015-10-13 23:48:28 +0000338if (NOT LIBCXX_ABI_VERSION EQUAL "1")
339 config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
340endif()
341config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
342
Eric Fiselier5cf9a822015-10-13 22:12:02 +0000343config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
344config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
345config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT)
346config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
347config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
348config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
349
350if (LIBCXX_NEEDS_SITE_CONFIG)
351 configure_file(
352 include/__config_site.in
353 ${LIBCXX_BINARY_DIR}/__config_site
354 @ONLY)
Eric Fiselier1a1c74b2015-10-14 00:22:05 +0000355 # Provide the config definitions by included the generated __config_site
356 # file at compile time.
357 add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
Eric Fiselier5cf9a822015-10-13 22:12:02 +0000358endif()
359
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000360#===============================================================================
Eric Fiselier156a46d2015-07-30 22:30:34 +0000361# Setup Source Code And Tests
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000362#===============================================================================
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000363include_directories(include)
Howard Hinnant6e207d52013-11-15 17:18:57 +0000364add_subdirectory(include)
Michael J. Spencer8d8164e2010-12-10 19:47:54 +0000365add_subdirectory(lib)
Eric Fiselierd720d1f2015-08-22 19:40:49 +0000366
Eric Fiselier156a46d2015-07-30 22:30:34 +0000367if (LIBCXX_INCLUDE_TESTS)
368 add_subdirectory(test)
369endif()
Eric Fiselierd720d1f2015-08-22 19:40:49 +0000370if (LIBCXX_INCLUDE_DOCS)
371 add_subdirectory(docs)
372endif()