diff --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh --- a/libcxx/utils/ci/apple-install-libcxx.sh +++ b/libcxx/utils/ci/apple-install-libcxx.sh @@ -158,7 +158,6 @@ any_arch=$(echo ${architectures} | cut -d ' ' -f 1) mkdir -p "${install_dir}/usr/include" ditto "${build_dir}/${any_arch}-install/include" "${install_dir}/usr/include" -ditto "${llvm_root}/libcxxabi/include" "${install_dir}/usr/include" # TODO: libcxxabi should install its headers in CMake if [[ $EUID -eq 0 ]]; then # Only chown if we're running as root chown -R root:wheel "${install_dir}/usr/include" fi diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -121,7 +121,9 @@ option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS}) set(LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") +option(LIBCXXABI_INSTALL_HEADERS "Install the libc++abi headers." ON) option(LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON) +set(LIBCXXABI_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH "Path to install the libc++abi headers at.") if(NOT CMAKE_SYSROOT AND LIBCXXABI_SYSROOT) message(WARNING "LIBCXXABI_SYSROOT is deprecated, please use CMAKE_SYSROOT instead") @@ -541,7 +543,6 @@ set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH "Specify path to libunwind source." FORCE) -include_directories(include) if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM) find_path(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES} @@ -565,6 +566,7 @@ # Add source code. This also contains all of the logic for deciding linker flags # soname, etc... +add_subdirectory(include) add_subdirectory(src) if (LIBCXXABI_INCLUDE_TESTS) diff --git a/libcxxabi/include/CMakeLists.txt b/libcxxabi/include/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/libcxxabi/include/CMakeLists.txt @@ -0,0 +1,26 @@ +set(files + __cxxabi_config.h + cxxabi.h + ) + +add_library(cxxabi-headers INTERFACE) +target_include_directories(cxxabi-headers INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}") + +if (LIBCXXABI_INSTALL_HEADERS) + foreach(file ${files}) + get_filename_component(dir ${file} DIRECTORY) + install(FILES ${file} + DESTINATION ${LIBCXXABI_INSTALL_INCLUDE_DIR}/${dir} + COMPONENT cxxabi-headers + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) + endforeach() + + add_custom_target(install-cxxabi-headers + DEPENDS cxxabi-headers + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=cxxabi-headers + -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") + # Stripping is a no-op for headers + add_custom_target(install-cxxabi-headers-stripped DEPENDS install-cxxabi-headers) +endif() diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -178,6 +178,7 @@ if (LIBCXXABI_ENABLE_SHARED) add_library(cxxabi_shared SHARED ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) target_link_libraries(cxxabi_shared PRIVATE cxx-headers ${LIBCXXABI_SHARED_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_shared PUBLIC cxxabi-headers) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_shared PUBLIC pstl::ParallelSTL) endif() @@ -233,6 +234,7 @@ if (LIBCXXABI_ENABLE_STATIC) add_library(cxxabi_static STATIC ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) target_link_libraries(cxxabi_static PRIVATE cxx-headers ${LIBCXXABI_STATIC_LIBRARIES} ${LIBCXXABI_LIBRARIES}) + target_link_libraries(cxxabi_static PUBLIC cxxabi-headers) if (TARGET pstl::ParallelSTL) target_link_libraries(cxxabi_static PUBLIC pstl::ParallelSTL) endif() @@ -299,7 +301,7 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND LIBCXXABI_INSTALL_LIBRARY) add_custom_target(install-cxxabi - DEPENDS cxxabi + DEPENDS cxxabi install-cxxabi-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=cxxabi -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake")