diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -20,8 +20,6 @@ set(LIBCXXABI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXXABI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -set(LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH - "Specify path to libc++ source.") include(GNUInstallDirs) @@ -92,7 +90,6 @@ message(WARNING "LIBCXXABI_SYSROOT, LIBCXXABI_TARGET_TRIPLE and LIBCXXABI_GCC_TOOLCHAIN are not supported anymore, please use the native CMake equivalents instead") endif() -set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library.") 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 \ @@ -131,10 +128,7 @@ message(FATAL_ERROR "libc++abi must be built as either a shared or static library.") endif() -# TODO: Remove this, which shouldn't be necessary since we know we're being built -# side-by-side with libc++. -set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH - "Specify path to libc++ includes.") +include(HandleLibCXX) set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) if (WIN32) @@ -174,13 +168,6 @@ # 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} - ) - set(LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Path where built libc++abi runtime libraries should be installed.") @@ -209,12 +196,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXXABI_LIBRARY_DIR}) -# By default, libcxx and libcxxabi share a library directory. -if (NOT LIBCXXABI_LIBCXX_LIBRARY_PATH) - set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH - "The path to libc++ library." FORCE) -endif() - # Declare libc++abi configuration variables. # They are intended for use as follows: # LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker. diff --git a/libcxxabi/cmake/Modules/HandleLibCXX.cmake b/libcxxabi/cmake/Modules/HandleLibCXX.cmake new file mode 100644 --- /dev/null +++ b/libcxxabi/cmake/Modules/HandleLibCXX.cmake @@ -0,0 +1,31 @@ +set(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_SOURCE_DIR}/../libcxx" CACHE PATH + "Specify path to libc++ source.") + +option(LIBCXXABI_USE_PREBUILT_LIBCXX_HEADERS + "Use prebuilt libc++ headers because we are not also building libcc++." + OFF) + +# TODO: Move this under the conditional. All usages should use `cxx-headers` +# instead of this, so this is us used to make the "fake" cxx-headers below and +# nothing else. +set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH + "Specify path to libc++ includes.") +if (LIBCXXABI_USE_PREBUILT_LIBCXX_HEADERS) + if (NOT IS_DIRECTORY ${LIBCXXABI_LIBCXX_INCLUDES}) + message(FATAL_ERROR + "LIBCXXABI_LIBCXX_INCLUDES=${LIBCXXABI_LIBCXX_INCLUDES} is not a valid directory. " + "Since we are not also building libc++, " + "please provide the path to where the libc++ headers have been installed.") + + endif() + add_library(cxx-headers INTERFACE) + target_include_directories(cxx-headers INTERFACE "${LIBCXXABI_LIBCXX_INCLUDES}") +endif() + +if (LIBCXXABI_INCLUDE_TESTS) + # The libraries are just needed for the "lit tests" + + # By default, libcxx and libcxxabi share a library directory. + set(LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH + "The path to libc++ library.") +endif()