aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
commit0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch)
tree051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /CMakeLists.txt
parent868847c6900e575417c03bced6e562b3af891318 (diff)
downloadsrc-0dc0969cd0a732760f0aa79942a04e0eaef297c4.tar.gz
src-0dc0969cd0a732760f0aa79942a04e0eaef297c4.zip
Vendor import of libc++ trunk r300422:vendor/libc++/libc++-trunk-r300422
Notes
Notes: svn path=/vendor/libc++/dist/; revision=317023 svn path=/vendor/libc++/libc++-trunk-r300422/; revision=317024; tag=vendor/libc++/libc++-trunk-r300422
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt100
1 files changed, 75 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a692f1b57a28..e2ee1e52d2e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,12 +19,11 @@ set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
)
-
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libcxx CXX C)
set(PACKAGE_NAME libcxx)
- set(PACKAGE_VERSION 4.0.0)
+ set(PACKAGE_VERSION 5.0.0svn)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
@@ -32,6 +31,15 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(HandleOutOfTreeLLVM)
endif()
+if (LIBCXX_STANDALONE_BUILD)
+ include(FindPythonInterp)
+ if( NOT PYTHONINTERP_FOUND )
+ message(WARNING "Failed to find python interpreter. "
+ "The libc++ test suite will be disabled.")
+ set(LLVM_INCLUDE_TESTS OFF)
+ endif()
+endif()
+
# Require out of source build.
include(MacroEnsureOutOfSourceBuild)
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
@@ -39,13 +47,20 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
)
+if (MSVC)
+ set(LIBCXX_TARGETING_MSVC ON)
+else()
+ set(LIBCXX_TARGETING_MSVC OFF)
+endif()
+
#===============================================================================
# Setup CMake Options
#===============================================================================
include(CMakeDependentOption)
+include(HandleCompilerRT)
# Basic options ---------------------------------------------------------------
-option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
+option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON)
option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
@@ -89,18 +104,9 @@ endif()
# ABI Library options ---------------------------------------------------------
set(LIBCXX_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use.")
-set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
+set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
-# FIXME: This is a temporary hack to force LLVM buildbots to store
-# the fixed cache entry instead of the previous cache entry. This is needed
-# because some LLVM buildbots don't clear their cache. It will be removed
-# once all LLVM bots have been run.
-if (LIBCXX_CXX_ABI STREQUAL "")
- set(LIBCXX_CXX_ABI "default" CACHE STRING
- "Specify the C++ ABI library to use." FORCE)
-endif()
-
# Setup the default options if LIBCXX_CXX_ABI is not specified.
if (LIBCXX_CXX_ABI STREQUAL "default")
find_path(
@@ -110,15 +116,18 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
NO_DEFAULT_PATH
)
- if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND
+ if ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND
IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_INTREE 1)
else()
- if (WIN32 AND NOT MINGW)
+ if (LIBCXX_TARGETING_MSVC)
# FIXME: Figure out how to configure the ABI library on Windows.
- set(LIBCXX_CXX_ABI_LIBNAME "none")
+ set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
+ elseif(APPLE)
+ set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
+ set(LIBCXX_CXX_ABI_SYSTEM 1)
else()
set(LIBCXX_CXX_ABI_LIBNAME "default")
endif()
@@ -133,7 +142,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
# Generate and install a linker script inplace of libc++.so. The linker script
# will link libc++ to the correct ABI library. This option is on by default
-# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
+# on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY'
# is on. This option is also disabled when the ABI library is not specified
# or is specified to be "none".
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
@@ -149,9 +158,25 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
"Use and install a linker script for the given ABI library"
${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE})
+set(ENABLE_NEW_DELETE_DEFAULT ON)
+if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
+# FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link
+# programs due to undefined references to new/delete in libc++abi so to work
+# around this libc++abi currently defaults LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
+# to ON. Once the GCC bug has been worked around this option should be changed
+# back to OFF.
+ set(ENABLE_NEW_DELETE_DEFAULT ON)
+endif()
+
+option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS
+ "Build libc++ with definitions for operator new/delete. This option can
+ be used to disable the definitions when libc++abi is expected to provide
+ them" ${ENABLE_NEW_DELETE_DEFAULT})
+
# Build libc++abi with libunwind. We need this option to determine whether to
# link with libunwind or libgcc_s while running the test cases.
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
+option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
# Target options --------------------------------------------------------------
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
@@ -316,10 +341,13 @@ endif()
set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build")
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
+file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
# Declare libc++ configuration variables.
# They are intended for use as follows:
@@ -342,9 +370,9 @@ include(HandleLibcxxFlags)
# 'config-ix' use them during feature checks. It also adds them to both
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'
add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32")
-add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
+add_target_flags_if(LIBCXX_TARGET_TRIPLE "--target=${LIBCXX_TARGET_TRIPLE}")
add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}")
-add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
+add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
if (LIBCXX_TARGET_TRIPLE)
set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}")
endif()
@@ -363,6 +391,11 @@ if (LIBCXX_GENERATE_COVERAGE)
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
+if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ set(LIBCXX_DEBUG_BUILD ON)
+else()
+ set(LIBCXX_DEBUG_BUILD OFF)
+endif()
#===============================================================================
# Setup Compiler Flags
@@ -373,13 +406,18 @@ include(HandleLibCXXABI) # Setup the ABI library flags
if (NOT LIBCXX_STANDALONE_BUILD)
# Remove flags that may have snuck in.
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -lc++abi -m32)
+ -lc++abi)
endif()
remove_flags(-stdlib=libc++ -stdlib=libstdc++)
+# FIXME: Remove all debug flags and flags that change which Windows
+# default libraries are linked. Currently we only support linking the
+# non-debug DLLs
+remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md")
+
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
-# so they don't get transformed into -Wno and -errors respectivly.
+# so they don't get transformed into -Wno and -errors respectively.
remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
# Required flags ==============================================================
@@ -412,6 +450,10 @@ add_compile_flags_if_supported(-fvisibility-inlines-hidden)
# library.
add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
+if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
+ add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
+endif()
+
# Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
add_compile_flags_if_supported(
@@ -425,7 +467,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
add_compile_flags_if_supported(
-Wno-literal-suffix
- -Wno-c++14-compat)
+ -Wno-c++14-compat
+ -Wno-noexcept-type)
endif()
if (LIBCXX_ENABLE_WERROR)
add_compile_flags_if_supported(-Werror)
@@ -474,9 +517,11 @@ endif()
# Assertion flags =============================================================
define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
-if (LIBCXX_ENABLE_ASSERTIONS)
+define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0)
+define_if(LIBCXX_DEBUG_BUILD -D_DEBUG)
+if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD)
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
- define_if_not(MSVC -D_DEBUG)
+ define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG)
endif()
# Modules flags ===============================================================
@@ -576,10 +621,15 @@ add_subdirectory(lib)
if (LIBCXX_INCLUDE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
+
+# Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or
+# LLVM_FOUND is OFF. This allows users to run the tests manually using
+# LIT without requiring a full LLVM checkout.
+add_subdirectory(test)
if (LIBCXX_INCLUDE_TESTS)
- add_subdirectory(test)
add_subdirectory(lib/abi)
endif()
+
if (LIBCXX_INCLUDE_DOCS)
add_subdirectory(docs)
endif()