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) @@ -37,6 +35,7 @@ #=============================================================================== include(CMakeDependentOption) include(HandleCompilerRT) +include(HandleLibCXX) # Define options. option(LIBCXXABI_ENABLE_EXCEPTIONS @@ -92,7 +91,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,11 +129,6 @@ 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.") - set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT OFF) if (WIN32) set(LIBCXXABI_HERMETIC_STATIC_LIBRARY_DEFAULT ON) @@ -209,12 +202,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,27 @@ +set(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_SOURCE_DIR}/../libcxx" CACHE PATH + "Specify path to libc++ source.") + +# 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 (NOT TARGET cxx-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()