diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -156,9 +156,23 @@ message(FATAL_ERROR "libc++abi must be built as either a shared or static library.") endif() -set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXABI_LIBCXX_PATH}/include" CACHE PATH - "Specify path to libc++ includes.") -message(STATUS "Libc++abi will be using libc++ includes from ${LIBCXXABI_LIBCXX_INCLUDES}") +# TODO: This is a workaround for the fact that Standalone builds can't use +# targets from the other runtimes (so the cxx-headers target doesn't exist). +set(LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH + "Specify path to the installed libc++ includes. This is only relevant for Standalone builds, where the location of the headers can't be determined automatically.") +if (LIBCXXABI_STANDALONE_BUILD) + if (NOT IS_DIRECTORY ${LIBCXXABI_LIBCXX_INCLUDES}) + message(FATAL_ERROR + "LIBCXXABI_LIBCXX_INCLUDES=${LIBCXXABI_LIBCXX_INCLUDES} is not a valid directory. " + "Please provide the path to where the libc++ headers have been installed.") + endif() + add_library(cxx-headers INTERFACE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(cxx-headers INTERFACE /I "${LIBCXXABI_LIBCXX_INCLUDES}") + else() + target_compile_options(cxx-headers INTERFACE -I "${LIBCXXABI_LIBCXX_INCLUDES}") + endif() +endif() option(LIBCXXABI_HERMETIC_STATIC_LIBRARY "Do not export any symbols from the static library." OFF) @@ -375,11 +389,6 @@ " be set to ON when LIBCXXABI_ENABLE_THREADS" " is also set to ON.") endif() - if (LIBCXXABI_HAS_WIN32_THREAD_API) - message(FATAL_ERROR "LIBCXXABI_HAS_WIN32_THREAD_API can only" - " be set to ON when LIBCXXABI_ENABLE_THREADS" - " is also set to ON.") - endif() if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only" " be set to ON when LIBCXXABI_ENABLE_THREADS" @@ -400,11 +409,6 @@ " and LIBCXXABI_HAS_PTHREAD_API cannot be both" " set to ON at the same time.") endif() - if (LIBCXXABI_HAS_WIN32_THREAD_API) - message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" - " and LIBCXXABI_HAS_WIN32_THREAD_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" @@ -412,14 +416,6 @@ endif() endif() -if (LIBCXXABI_HAS_PTHREAD_API) - if (LIBCXXABI_HAS_WIN32_THREAD_API) - message(FATAL_ERROR "The options LIBCXXABI_HAS_PTHREAD_API" - "and LIBCXXABI_HAS_WIN32_THREAD_API cannot be both" - "set to ON at the same time.") - endif() -endif() - 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) @@ -447,10 +443,6 @@ add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD) endif() -if (LIBCXXABI_HAS_WIN32_THREAD_API) - add_definitions(-D_LIBCPP_HAS_THREAD_API_WIN32) -endif() - if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL) endif() diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -177,7 +177,7 @@ # Build the shared library. if (LIBCXXABI_ENABLE_SHARED) add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) - target_link_libraries(cxxabi_shared PRIVATE ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) endif() @@ -244,7 +244,7 @@ # Build the static library. if (LIBCXXABI_ENABLE_STATIC) add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) - target_link_libraries(cxxabi_static PRIVATE ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_static PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) endif()