2017-06-01 08:09:20 +08:00
|
|
|
# See www/CMake.html for instructions on how to build libcxxabi with CMake.
|
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup Project
|
|
|
|
#===============================================================================
|
|
|
|
|
2016-06-01 04:21:53 +08:00
|
|
|
cmake_minimum_required(VERSION 3.4.3)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
2015-01-27 06:00:30 +08:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
|
|
|
|
endif()
|
|
|
|
|
2017-04-08 04:10:41 +08:00
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
)
|
|
|
|
|
2019-02-17 20:16:20 +08:00
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD)
|
2017-06-01 08:09:20 +08:00
|
|
|
project(libcxxabi CXX C)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
|
|
|
set(PACKAGE_NAME libcxxabi)
|
2020-01-31 04:18:24 +08:00
|
|
|
set(PACKAGE_VERSION 11.0.0git)
|
2014-07-04 03:35:48 +08:00
|
|
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
2015-08-05 12:01:26 +08:00
|
|
|
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
2014-07-04 03:35:48 +08:00
|
|
|
|
2017-06-01 08:09:20 +08:00
|
|
|
# Find the LLVM sources and simulate LLVM CMake options.
|
|
|
|
include(HandleOutOfTreeLLVM)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
|
2017-06-01 08:09:20 +08:00
|
|
|
# Require out of source build.
|
|
|
|
include(MacroEnsureOutOfSourceBuild)
|
|
|
|
MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
|
|
|
|
"${PROJECT_NAME} requires an out of source build. Please create a separate
|
|
|
|
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
|
|
|
|
)
|
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Setup CMake Options
|
|
|
|
#===============================================================================
|
2017-06-01 08:09:20 +08:00
|
|
|
include(CMakeDependentOption)
|
2017-04-08 04:10:41 +08:00
|
|
|
include(HandleCompilerRT)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
|
|
|
# Define options.
|
2019-07-13 03:10:59 +08:00
|
|
|
option(LIBCXXABI_ENABLE_EXCEPTIONS
|
|
|
|
"Provide support for exceptions in the runtime.
|
|
|
|
When disabled, libc++abi does not support stack unwinding and other exceptions-related features." ON)
|
2014-07-04 03:35:48 +08:00
|
|
|
option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
|
|
|
|
option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
2019-04-03 08:34:12 +08:00
|
|
|
option(LIBCXXABI_ENABLE_PIC "Build Position-Independent Code, even in static library" ON)
|
2014-07-04 03:35:48 +08:00
|
|
|
option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
|
2015-04-28 10:09:53 +08:00
|
|
|
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
|
2017-02-09 10:19:30 +08:00
|
|
|
option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF)
|
2016-07-15 08:49:42 +08:00
|
|
|
option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
2014-11-25 06:42:03 +08:00
|
|
|
option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
|
2016-05-26 01:37:38 +08:00
|
|
|
option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
|
2017-01-03 20:58:34 +08:00
|
|
|
option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
|
|
|
|
"Build libc++abi with an externalized threading API.
|
|
|
|
This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF)
|
2017-01-09 19:57:21 +08:00
|
|
|
option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
|
|
|
|
"Build libc++abi with an externalized threading library.
|
|
|
|
This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF)
|
2017-03-03 05:55:17 +08:00
|
|
|
|
|
|
|
# FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link
|
|
|
|
# programs to due undefined references to new/delete in libc++abi. Once this
|
|
|
|
# has been fixed or worked around the default value should be changed.
|
2017-03-03 03:34:35 +08:00
|
|
|
option(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
|
|
|
|
"Build libc++abi with definitions for operator new/delete. Normally libc++
|
2017-03-03 05:55:17 +08:00
|
|
|
provides these definitions" ON)
|
2016-06-02 10:18:31 +08:00
|
|
|
option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS})
|
2017-01-08 06:14:04 +08:00
|
|
|
option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS})
|
2017-06-13 16:16:44 +08:00
|
|
|
set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
|
|
|
|
"Define suffix of library directory name (32/64)")
|
2017-11-18 07:25:09 +08:00
|
|
|
option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON)
|
2016-06-02 10:18:31 +08:00
|
|
|
set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
|
2016-06-01 20:50:30 +08:00
|
|
|
set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
|
|
|
|
set(LIBCXXABI_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
|
|
|
|
set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.")
|
2019-10-08 03:22:04 +08:00
|
|
|
set(LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
|
|
|
|
"Version of libc++abi. This will be reflected in the name of the shared \
|
|
|
|
library produced. For example, -DLIBCXXABI_LIBRARY_VERSION=x.y will \
|
|
|
|
result in the library being named libc++abi.x.y.dylib, along with the \
|
|
|
|
usual symlinks pointing to that.")
|
2014-07-10 10:20:11 +08:00
|
|
|
|
|
|
|
# Default to building a shared library so that the default options still test
|
|
|
|
# the libc++abi that is being built. There are two problems with testing a
|
|
|
|
# static libc++abi. In the case of a standalone build, the tests will link the
|
|
|
|
# system's libc++, which might not have been built against our libc++abi. In the
|
|
|
|
# case of an in tree build, libc++ will prefer a dynamic libc++abi from the
|
|
|
|
# system over a static libc++abi from the output directory.
|
|
|
|
option(LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON)
|
2015-03-03 23:59:09 +08:00
|
|
|
option(LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON)
|
|
|
|
|
[libcxxabi] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
Right now the only way to force libc++abi tests to link with the static version of libc++abi is to set `LIBCXXABI_ENABLE_SHARED` to `OFF`. However, this doesn't work when libc++abi is built as standalone project because of [this](https://github.com/llvm/llvm-project/blob/54c522420347e58aa7bae1892cf5c5672b57c875/libcxxabi/CMakeLists.txt#L503-L519).
This change allows specifying the version of the library for tests to link with.
This is useful for remote testing, for example, with `SSHExecutor`, where we _have_ to link with libc++abi statically.
Two new CMake options are introduced here: `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI` and `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX`. They can be set to `OFF` to tell the test utility to link tests with the static libraries.
It shouldn't break anything, because the default values of these options are set such that the test utility will behave the same way.
Reviewers: EricWF, mclow.lists, phosek, mehdi_amini, ldionne, jroelofs, bcraig
Subscribers: mgorny, christof, ldionne, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D71894
2019-12-26 17:28:39 +08:00
|
|
|
option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI
|
|
|
|
"Whether the libc++abi tests should link with the shared libc++abi library"
|
|
|
|
${LIBCXXABI_ENABLE_SHARED})
|
|
|
|
|
|
|
|
option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
|
|
|
|
"Whether the libc++abi tests should link with the shared libc++ library"
|
|
|
|
${LIBCXX_ENABLE_SHARED})
|
|
|
|
|
2018-07-26 07:13:00 +08:00
|
|
|
cmake_dependent_option(LIBCXXABI_INSTALL_STATIC_LIBRARY
|
|
|
|
"Install the static libc++abi library." ON
|
|
|
|
"LIBCXXABI_ENABLE_STATIC;LIBCXXABI_INSTALL_LIBRARY" OFF)
|
|
|
|
cmake_dependent_option(LIBCXXABI_INSTALL_SHARED_LIBRARY
|
|
|
|
"Install the shared libc++abi library." ON
|
|
|
|
"LIBCXXABI_ENABLE_SHARED;LIBCXXABI_INSTALL_LIBRARY" OFF)
|
|
|
|
|
2018-07-24 15:06:17 +08:00
|
|
|
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
|
|
|
|
"Statically link the LLVM unwinder to static library" ON
|
|
|
|
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_STATIC" OFF)
|
|
|
|
cmake_dependent_option(LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
|
|
|
|
"Statically link the LLVM unwinder to shared library" ON
|
|
|
|
"LIBCXXABI_ENABLE_STATIC_UNWINDER;LIBCXXABI_ENABLE_SHARED" OFF)
|
|
|
|
|
2017-03-01 19:42:01 +08:00
|
|
|
option(LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF)
|
|
|
|
# The default terminate handler attempts to demangle uncaught exceptions, which
|
|
|
|
# causes extra I/O and demangling code to be pulled in.
|
|
|
|
option(LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF)
|
|
|
|
|
2015-03-03 23:59:09 +08:00
|
|
|
if (NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
|
|
|
|
endif()
|
2014-07-10 10:20:11 +08:00
|
|
|
|
[libcxxabi] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
Right now the only way to force libc++abi tests to link with the static version of libc++abi is to set `LIBCXXABI_ENABLE_SHARED` to `OFF`. However, this doesn't work when libc++abi is built as standalone project because of [this](https://github.com/llvm/llvm-project/blob/54c522420347e58aa7bae1892cf5c5672b57c875/libcxxabi/CMakeLists.txt#L503-L519).
This change allows specifying the version of the library for tests to link with.
This is useful for remote testing, for example, with `SSHExecutor`, where we _have_ to link with libc++abi statically.
Two new CMake options are introduced here: `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI` and `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX`. They can be set to `OFF` to tell the test utility to link tests with the static libraries.
It shouldn't break anything, because the default values of these options are set such that the test utility will behave the same way.
Reviewers: EricWF, mclow.lists, phosek, mehdi_amini, ldionne, jroelofs, bcraig
Subscribers: mgorny, christof, ldionne, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D71894
2019-12-26 17:28:39 +08:00
|
|
|
if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED LIBCXX_ENABLE_SHARED
|
|
|
|
AND LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
|
|
|
|
AND NOT LIBCXX_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED LIBCXX_ENABLE_STATIC
|
|
|
|
AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
|
|
|
|
AND NOT LIBCXX_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
2016-11-08 06:07:43 +08:00
|
|
|
if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR)
|
2016-11-12 03:12:58 +08:00
|
|
|
set(LIBCXXABI_LIBCXX_SRC_DIRS ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR})
|
2016-11-08 06:07:43 +08:00
|
|
|
else()
|
2016-11-12 03:12:58 +08:00
|
|
|
set(LIBCXXABI_LIBCXX_SRC_DIRS
|
|
|
|
"${LLVM_MAIN_SRC_DIR}/projects/libcxx"
|
|
|
|
"${LLVM_MAIN_SRC_DIR}/runtimes/libcxx"
|
2018-04-05 01:40:59 +08:00
|
|
|
"${LLVM_MAIN_SRC_DIR}/../libcxx"
|
2016-11-12 03:12:58 +08:00
|
|
|
)
|
2016-11-08 06:07:43 +08:00
|
|
|
endif()
|
|
|
|
|
2016-11-12 03:12:58 +08:00
|
|
|
set(LIBCXXABI_LIBCXX_INCLUDE_DIRS "")
|
|
|
|
foreach(dir ${LIBCXXABI_LIBCXX_SRC_DIRS})
|
|
|
|
list(APPEND LIBCXXABI_LIBCXX_INCLUDE_DIRS "${dir}/include")
|
|
|
|
endforeach()
|
|
|
|
|
2014-07-10 10:20:11 +08:00
|
|
|
find_path(
|
|
|
|
LIBCXXABI_LIBCXX_INCLUDES
|
2018-06-30 09:25:47 +08:00
|
|
|
__config
|
2014-07-10 10:20:11 +08:00
|
|
|
PATHS ${LIBCXXABI_LIBCXX_INCLUDES}
|
2015-01-23 04:00:06 +08:00
|
|
|
${LIBCXXABI_LIBCXX_PATH}/include
|
2014-07-10 10:20:11 +08:00
|
|
|
${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
|
2016-11-12 03:12:58 +08:00
|
|
|
${LIBCXXABI_LIBCXX_INCLUDE_DIRS}
|
2014-07-10 10:20:11 +08:00
|
|
|
${LLVM_INCLUDE_DIR}/c++/v1
|
[libc++abi] Limit libc++ header search to specified paths
Right now, when libc++abi is locating libc++ headers, it specifies
several search locations, but it also doesn't prevent CMake from looking
for those headers in system directories. I don't know if this was
intentional or an oversight, but it has several issues:
* We're looking specifically for the vector header, which could just as
easily be found in a libstdc++ (or other C++ library) installation.
* No system I know of places their C++ headers directly in system
include directories (they're always under a C++ subdirectory), so the
system search will never succeed.
* find_path searches system paths before the user-specified PATHS, so
if some system does happen to have C++ headers in its system include
directories, those headers will be preferred, which doesn't seem
desirable.
It makes sense to me to limit this header search to the explicitly
specified paths (using NO_DEFAULT_PATH, as is done for the other
find_path call in this file), but I'm putting it up for review in case
there's some use case I'm not thinking of.
Differential Revision: https://reviews.llvm.org/D48694
llvm-svn: 336032
2018-06-30 09:04:50 +08:00
|
|
|
NO_DEFAULT_PATH
|
2018-01-23 03:41:05 +08:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
2014-07-10 10:20:11 +08:00
|
|
|
)
|
|
|
|
|
2015-01-23 04:00:06 +08:00
|
|
|
set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_INCLUDES}" CACHE PATH
|
2014-07-10 10:20:11 +08:00
|
|
|
"Specify path to libc++ includes." FORCE)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
2015-01-23 04:00:06 +08:00
|
|
|
find_path(
|
|
|
|
LIBCXXABI_LIBCXX_PATH
|
2017-02-18 12:37:59 +08:00
|
|
|
utils/libcxx/test/__init__.py
|
2015-01-23 04:00:06 +08:00
|
|
|
PATHS ${LIBCXXABI_LIBCXX_PATH}
|
|
|
|
${LIBCXXABI_LIBCXX_INCLUDES}/../
|
2016-11-12 03:12:58 +08:00
|
|
|
${LIBCXXABI_LIBCXX_SRC_DIRS}
|
2015-01-23 04:00:06 +08:00
|
|
|
NO_DEFAULT_PATH
|
2018-01-23 03:41:05 +08:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
2015-01-23 04:00:06 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if (LIBCXXABI_LIBCXX_PATH STREQUAL "LIBCXXABI_LIBCXX_PATH-NOTFOUND")
|
|
|
|
message(WARNING "LIBCXXABI_LIBCXX_PATH was not specified and couldn't be infered.")
|
|
|
|
set(LIBCXXABI_LIBCXX_PATH "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_LIBCXX_PATH}" CACHE PATH
|
|
|
|
"Specify path to libc++ source." FORCE)
|
|
|
|
|
2019-01-24 11:18:29 +08:00
|
|
|
option(LIBCXXABI_HERMETIC_STATIC_LIBRARY
|
|
|
|
"Do not export any symbols from the static library." OFF)
|
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Configure System
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
# Add path for custom modules
|
|
|
|
set(CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
)
|
|
|
|
|
2014-12-29 20:22:04 +08:00
|
|
|
set(LIBCXXABI_COMPILER ${CMAKE_CXX_COMPILER})
|
|
|
|
set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2018-06-28 11:11:52 +08:00
|
|
|
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|
|
|
${PACKAGE_VERSION})
|
|
|
|
|
|
|
|
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
|
|
|
|
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++)
|
|
|
|
if(LIBCXX_LIBDIR_SUBDIR)
|
|
|
|
string(APPEND LIBCXXABI_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
|
|
|
|
string(APPEND LIBCXXABI_INSTALL_LIBRARY_DIR /${LIBCXXABI_LIBDIR_SUBDIR})
|
|
|
|
endif()
|
2018-06-28 11:11:52 +08:00
|
|
|
elseif(LLVM_LIBRARY_OUTPUT_INTDIR)
|
2017-05-04 14:04:49 +08:00
|
|
|
set(LIBCXXABI_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
|
2017-05-04 14:04:49 +08:00
|
|
|
else()
|
2018-07-26 00:51:00 +08:00
|
|
|
set(LIBCXXABI_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXXABI_LIBDIR_SUFFIX})
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBCXXABI_INSTALL_LIBRARY_DIR lib${LIBCXXABI_LIBDIR_SUFFIX})
|
2017-05-04 14:04:49 +08:00
|
|
|
endif()
|
2014-12-29 20:22:04 +08:00
|
|
|
|
2019-05-23 05:08:33 +08:00
|
|
|
set(LIBCXXABI_INSTALL_PREFIX "" CACHE STRING "Define libc++abi destination prefix.")
|
2017-07-11 09:42:26 +08:00
|
|
|
|
2016-04-18 21:30:38 +08:00
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
2017-06-01 08:09:20 +08:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR})
|
2016-04-18 21:30:38 +08:00
|
|
|
|
2016-06-01 20:50:30 +08:00
|
|
|
# By default, for non-standalone builds, libcxx and libcxxabi share a library
|
|
|
|
# directory.
|
|
|
|
if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH)
|
|
|
|
set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
|
[libcxxabi] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
Right now the only way to force libc++abi tests to link with the static version of libc++abi is to set `LIBCXXABI_ENABLE_SHARED` to `OFF`. However, this doesn't work when libc++abi is built as standalone project because of [this](https://github.com/llvm/llvm-project/blob/54c522420347e58aa7bae1892cf5c5672b57c875/libcxxabi/CMakeLists.txt#L503-L519).
This change allows specifying the version of the library for tests to link with.
This is useful for remote testing, for example, with `SSHExecutor`, where we _have_ to link with libc++abi statically.
Two new CMake options are introduced here: `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI` and `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX`. They can be set to `OFF` to tell the test utility to link tests with the static libraries.
It shouldn't break anything, because the default values of these options are set such that the test utility will behave the same way.
Reviewers: EricWF, mclow.lists, phosek, mehdi_amini, ldionne, jroelofs, bcraig
Subscribers: mgorny, christof, ldionne, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D71894
2019-12-26 17:28:39 +08:00
|
|
|
"The path to libc++ library." FORCE)
|
2016-08-09 01:59:02 +08:00
|
|
|
endif()
|
2016-06-02 10:18:31 +08:00
|
|
|
|
|
|
|
# Check that we can build with 32 bits if requested.
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
|
|
|
|
if (LIBCXXABI_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
|
|
|
|
message(STATUS "Building 32 bits executables and libraries.")
|
|
|
|
endif()
|
|
|
|
elseif(LIBCXXABI_BUILD_32_BITS)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_BUILD_32_BITS=ON is not supported on this platform.")
|
|
|
|
endif()
|
|
|
|
|
2017-06-01 08:09:20 +08:00
|
|
|
# Declare libc++abi configuration variables.
|
|
|
|
# They are intended for use as follows:
|
|
|
|
# LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker.
|
|
|
|
# LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker.
|
|
|
|
# LIBCXXABI_COMPILE_FLAGS: Compile only flags.
|
|
|
|
# LIBCXXABI_LINK_FLAGS: Linker only flags.
|
|
|
|
# LIBCXXABI_LIBRARIES: libraries libc++abi is linked to.
|
2016-06-02 10:18:31 +08:00
|
|
|
|
2015-01-22 21:39:08 +08:00
|
|
|
set(LIBCXXABI_C_FLAGS "")
|
2014-11-19 04:37:53 +08:00
|
|
|
set(LIBCXXABI_CXX_FLAGS "")
|
|
|
|
set(LIBCXXABI_COMPILE_FLAGS "")
|
|
|
|
set(LIBCXXABI_LINK_FLAGS "")
|
2017-06-01 08:09:20 +08:00
|
|
|
set(LIBCXXABI_LIBRARIES "")
|
|
|
|
|
|
|
|
# Include macros for adding and removing libc++abi flags.
|
|
|
|
include(HandleLibcxxabiFlags)
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Compiler Flags
|
|
|
|
#===============================================================================
|
2014-11-19 04:37:53 +08:00
|
|
|
|
2016-06-02 10:18:31 +08:00
|
|
|
# Configure target flags
|
|
|
|
add_target_flags_if(LIBCXXABI_BUILD_32_BITS "-m32")
|
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
|
|
|
|
|
|
|
if(LIBCXXABI_TARGET_TRIPLE)
|
|
|
|
add_target_flags("--target=${LIBCXXABI_TARGET_TRIPLE}")
|
|
|
|
elseif(CMAKE_CXX_COMPILER_TARGET)
|
|
|
|
set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}")
|
|
|
|
endif()
|
|
|
|
if(LIBCXX_GCC_TOOLCHAIN)
|
|
|
|
add_target_flags("--gcc-toolchain=${LIBCXXABI_GCC_TOOLCHAIN}")
|
|
|
|
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
|
|
|
|
set(LIBCXXABI_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}")
|
|
|
|
endif()
|
|
|
|
if(LIBCXXABI_SYSROOT)
|
|
|
|
add_target_flags("--sysroot=${LIBCXXABI_SYSROOT}")
|
|
|
|
elseif(CMAKE_SYSROOT)
|
|
|
|
set(LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}")
|
|
|
|
endif()
|
2016-06-02 10:18:31 +08:00
|
|
|
|
2016-11-14 06:27:00 +08:00
|
|
|
if (LIBCXXABI_TARGET_TRIPLE)
|
|
|
|
set(TARGET_TRIPLE "${LIBCXXABI_TARGET_TRIPLE}")
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 10:18:31 +08:00
|
|
|
# Configure compiler. Must happen after setting the target flags.
|
|
|
|
include(config-ix)
|
2014-11-19 04:37:53 +08:00
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
if (LIBCXXABI_HAS_NOSTDINCXX_FLAG)
|
2014-11-19 04:37:53 +08:00
|
|
|
list(APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++)
|
2019-11-08 06:51:25 +08:00
|
|
|
# cmake 3.14 and above remove system include paths that are explicitly
|
|
|
|
# passed on the command line. We build with -nostdinc++ and explicitly add
|
|
|
|
# just the libcxx system include paths with -I on the command line.
|
|
|
|
# Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effectively prevents cmake
|
|
|
|
# from removing these.
|
|
|
|
# See: https://gitlab.kitware.com/cmake/cmake/issues/19227
|
|
|
|
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "")
|
2014-11-19 04:37:53 +08:00
|
|
|
# Remove -stdlib flags to prevent them from causing an unused flag warning.
|
|
|
|
string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
|
2016-09-27 11:44:09 +08:00
|
|
|
# Let the library headers know they are currently being used to build the
|
|
|
|
# library.
|
|
|
|
add_definitions(-D_LIBCXXABI_BUILDING_LIBRARY)
|
|
|
|
|
|
|
|
# Disable DLL annotations on Windows for static builds.
|
|
|
|
if (WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED)
|
2017-05-29 06:46:50 +08:00
|
|
|
add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS)
|
2016-09-27 11:44:09 +08:00
|
|
|
endif()
|
|
|
|
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-Werror=return-type)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
|
|
|
# Get warning flags
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-W)
|
|
|
|
add_compile_flags_if_supported(-Wall)
|
|
|
|
add_compile_flags_if_supported(-Wchar-subscripts)
|
|
|
|
add_compile_flags_if_supported(-Wconversion)
|
|
|
|
add_compile_flags_if_supported(-Wmismatched-tags)
|
|
|
|
add_compile_flags_if_supported(-Wmissing-braces)
|
|
|
|
add_compile_flags_if_supported(-Wnewline-eof)
|
|
|
|
add_compile_flags_if_supported(-Wunused-function)
|
|
|
|
add_compile_flags_if_supported(-Wshadow)
|
|
|
|
add_compile_flags_if_supported(-Wshorten-64-to-32)
|
|
|
|
add_compile_flags_if_supported(-Wsign-compare)
|
|
|
|
add_compile_flags_if_supported(-Wsign-conversion)
|
|
|
|
add_compile_flags_if_supported(-Wstrict-aliasing=2)
|
|
|
|
add_compile_flags_if_supported(-Wstrict-overflow=4)
|
|
|
|
add_compile_flags_if_supported(-Wunused-parameter)
|
|
|
|
add_compile_flags_if_supported(-Wunused-variable)
|
|
|
|
add_compile_flags_if_supported(-Wwrite-strings)
|
|
|
|
add_compile_flags_if_supported(-Wundef)
|
2014-07-11 06:23:03 +08:00
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
if (LIBCXXABI_ENABLE_WERROR)
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-Werror)
|
|
|
|
add_compile_flags_if_supported(-WX)
|
2014-07-04 03:35:48 +08:00
|
|
|
else()
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-Wno-error)
|
|
|
|
add_compile_flags_if_supported(-WX-)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
if (LIBCXXABI_ENABLE_PEDANTIC)
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-pedantic)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Get feature flags.
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-fstrict-aliasing)
|
2014-07-04 03:35:48 +08:00
|
|
|
|
2016-05-31 20:01:32 +08:00
|
|
|
# Exceptions
|
|
|
|
if (LIBCXXABI_ENABLE_EXCEPTIONS)
|
|
|
|
# Catches C++ exceptions only and tells the compiler to assume that extern C
|
|
|
|
# functions never throw a C++ exception.
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-EHsc)
|
|
|
|
# Do we really need to be run through the C compiler ?
|
|
|
|
add_c_compile_flags_if_supported(-funwind-tables)
|
2016-05-31 20:01:32 +08:00
|
|
|
else()
|
|
|
|
add_definitions(-D_LIBCXXABI_NO_EXCEPTIONS)
|
2017-06-01 08:09:20 +08:00
|
|
|
add_compile_flags_if_supported(-fno-exceptions)
|
|
|
|
add_compile_flags_if_supported(-EHs-)
|
|
|
|
add_compile_flags_if_supported(-EHa-)
|
2016-05-31 20:01:32 +08:00
|
|
|
endif()
|
2015-01-22 21:39:08 +08:00
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
# Assert
|
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
|
|
|
|
if (LIBCXXABI_ENABLE_ASSERTIONS)
|
|
|
|
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
|
|
|
|
if (NOT MSVC)
|
2014-11-19 04:37:53 +08:00
|
|
|
list(APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
# On Release builds cmake automatically defines NDEBUG, so we
|
|
|
|
# explicitly undefine it:
|
|
|
|
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2014-11-19 04:37:53 +08:00
|
|
|
list(APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
2014-11-19 04:37:53 +08:00
|
|
|
list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
# Static library
|
|
|
|
if (NOT LIBCXXABI_ENABLE_SHARED)
|
2014-11-19 04:37:53 +08:00
|
|
|
list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
|
2014-07-04 03:35:48 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-03 20:58:34 +08:00
|
|
|
# Threading
|
2014-11-25 06:42:03 +08:00
|
|
|
if (NOT LIBCXXABI_ENABLE_THREADS)
|
2016-05-26 01:37:38 +08:00
|
|
|
if (LIBCXXABI_HAS_PTHREAD_API)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
|
|
|
|
" be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
|
|
" is also set to ON.")
|
|
|
|
endif()
|
2017-01-03 20:58:34 +08:00
|
|
|
if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only"
|
|
|
|
" be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
|
|
" is also set to ON.")
|
|
|
|
endif()
|
2017-01-09 19:57:21 +08:00
|
|
|
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only"
|
|
|
|
" be set to ON when LIBCXXABI_ENABLE_THREADS"
|
|
|
|
" is also set to ON.")
|
|
|
|
endif()
|
2016-09-21 17:09:32 +08:00
|
|
|
add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
|
2014-11-25 06:42:03 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-09 19:57:21 +08:00
|
|
|
if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
|
|
|
if (LIBCXXABI_HAS_PTHREAD_API)
|
|
|
|
message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
|
|
|
|
" and LIBCXXABI_HAS_PTHREAD_API cannot be both"
|
|
|
|
" set to ON at the same time.")
|
|
|
|
endif()
|
|
|
|
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
|
|
message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY"
|
|
|
|
" and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both"
|
|
|
|
" set to ON at the same time.")
|
|
|
|
endif()
|
2017-01-03 20:58:34 +08:00
|
|
|
endif()
|
|
|
|
|
2017-07-31 17:35:08 +08:00
|
|
|
if (LLVM_ENABLE_MODULES)
|
|
|
|
# Ignore that the rest of the modules flags are now unused.
|
|
|
|
add_compile_flags_if_supported(-Wno-unused-command-line-argument)
|
|
|
|
add_compile_flags(-fno-modules)
|
|
|
|
endif()
|
|
|
|
|
2017-03-04 10:15:37 +08:00
|
|
|
set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF)
|
|
|
|
if ((NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS)
|
2017-05-11 11:49:48 +08:00
|
|
|
OR (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED)
|
|
|
|
OR MINGW)
|
2017-03-04 10:15:37 +08:00
|
|
|
set(LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON)
|
|
|
|
endif()
|
2017-03-03 03:34:35 +08:00
|
|
|
|
|
|
|
if (LIBCXXABI_HAS_UNDEFINED_SYMBOLS)
|
2017-01-03 20:58:34 +08:00
|
|
|
# Need to allow unresolved symbols if this is to work with shared library builds
|
|
|
|
if (APPLE)
|
2017-03-04 10:15:37 +08:00
|
|
|
list(APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup")
|
2017-01-03 20:58:34 +08:00
|
|
|
else()
|
|
|
|
# Relax this restriction from HandleLLVMOptions
|
|
|
|
string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-05-26 01:37:38 +08:00
|
|
|
if (LIBCXXABI_HAS_PTHREAD_API)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
|
|
|
|
endif()
|
|
|
|
|
2017-01-03 20:58:34 +08:00
|
|
|
if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
|
2017-01-09 19:57:21 +08:00
|
|
|
add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
|
|
add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
|
2017-01-03 20:58:34 +08:00
|
|
|
endif()
|
|
|
|
|
2017-05-11 05:52:39 +08:00
|
|
|
# Prevent libc++abi from having library dependencies on libc++
|
|
|
|
add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE)
|
|
|
|
|
2018-04-30 07:05:11 +08:00
|
|
|
# Bring back `std::unexpected`, which is removed in C++17, to support
|
|
|
|
# pre-C++17.
|
|
|
|
add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS)
|
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
2015-01-22 21:27:36 +08:00
|
|
|
# Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation.
|
2016-11-13 22:42:15 +08:00
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER)
|
2017-03-01 19:42:01 +08:00
|
|
|
add_definitions(-DLIBCXXABI_USE_LLVM_UNWINDER)
|
2015-01-22 21:27:36 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-14 03:22:26 +08:00
|
|
|
if (LIBCXXABI_SILENT_TERMINATE)
|
2017-03-01 19:42:01 +08:00
|
|
|
add_definitions(-DLIBCXXABI_SILENT_TERMINATE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCXXABI_BAREMETAL)
|
|
|
|
add_definitions(-DLIBCXXABI_BAREMETAL)
|
2017-01-14 03:22:26 +08:00
|
|
|
endif()
|
|
|
|
|
2019-05-30 12:40:21 +08:00
|
|
|
if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
|
2019-12-02 18:49:20 +08:00
|
|
|
if (LIBCXXABI_HAS_PTHREAD_LIB)
|
|
|
|
add_definitions(-D_LIBCXXABI_LINK_PTHREAD_LIB)
|
|
|
|
endif()
|
2019-05-30 12:40:21 +08:00
|
|
|
endif()
|
|
|
|
|
2014-11-19 04:37:53 +08:00
|
|
|
string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
|
2015-01-22 21:39:08 +08:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
|
2014-07-04 03:35:48 +08:00
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Setup Source Code
|
|
|
|
#===============================================================================
|
|
|
|
|
2015-05-09 00:10:11 +08:00
|
|
|
set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
|
|
|
|
"Specify path to libunwind includes." FORCE)
|
|
|
|
set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
|
|
|
|
"Specify path to libunwind source." FORCE)
|
|
|
|
|
2014-07-04 03:35:48 +08:00
|
|
|
include_directories(include)
|
2015-04-29 23:53:03 +08:00
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
|
2019-05-03 01:29:39 +08:00
|
|
|
find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
|
2015-05-09 00:10:11 +08:00
|
|
|
PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
|
|
|
|
${LIBCXXABI_LIBUNWIND_PATH}/include
|
|
|
|
${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
|
|
|
|
${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
|
2016-11-12 03:12:58 +08:00
|
|
|
${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
|
2018-04-05 01:40:59 +08:00
|
|
|
${LLVM_MAIN_SRC_DIR}/../libunwind/include
|
2015-05-10 05:03:01 +08:00
|
|
|
NO_DEFAULT_PATH
|
2018-01-23 03:41:05 +08:00
|
|
|
NO_CMAKE_FIND_ROOT_PATH
|
2015-05-09 00:10:11 +08:00
|
|
|
)
|
|
|
|
|
2017-04-04 22:03:54 +08:00
|
|
|
if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
|
|
|
|
set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
|
2017-01-15 01:05:16 +08:00
|
|
|
include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
|
|
|
|
endif()
|
2016-08-09 01:59:02 +08:00
|
|
|
endif()
|
2014-07-04 03:35:48 +08:00
|
|
|
|
|
|
|
# Add source code. This also contains all of the logic for deciding linker flags
|
|
|
|
# soname, etc...
|
|
|
|
add_subdirectory(src)
|
2014-07-10 10:20:11 +08:00
|
|
|
|
2018-01-19 02:29:36 +08:00
|
|
|
if (LIBCXXABI_INCLUDE_TESTS)
|
|
|
|
if (LIBCXXABI_STANDALONE_BUILD AND NOT LIBCXXABI_ENABLE_SHARED)
|
|
|
|
# We can't reasonably test the system C++ library with a static
|
|
|
|
# libc++abi. We either need to be able to replace libc++abi at
|
|
|
|
# run time (with a shared libc++abi), or we need to be able to
|
|
|
|
# replace the C++ runtime (with a non- standalone build).
|
|
|
|
message(WARNING "The libc++abi tests aren't valid when libc++abi "
|
|
|
|
"is built standalone (i.e. outside of "
|
|
|
|
"llvm/projects/libcxxabi ) and is built without "
|
|
|
|
"a shared library. Either build a shared "
|
|
|
|
"library, build libc++abi at the same time as "
|
|
|
|
"you build libc++, or do without testing. No "
|
|
|
|
"check target will be available!")
|
|
|
|
else()
|
|
|
|
add_subdirectory(test)
|
|
|
|
add_subdirectory(fuzz)
|
|
|
|
endif()
|
2014-07-10 10:20:11 +08:00
|
|
|
endif()
|