[libc++abi] Install the libc++abi headers from libc++abi

libc++abi should be responsible for installing its own headers, it
doesn't make sense for libc++ to be responsible for it.

Differential Revision: https://reviews.llvm.org/D101458
This commit is contained in:
Louis Dionne 2022-02-17 11:19:45 -05:00
parent 8057a8e26a
commit 6dfdf79b8c
4 changed files with 32 additions and 3 deletions

View File

@ -158,7 +158,6 @@ step "Installing the libc++ and libc++abi headers to ${install_dir}/usr/include"
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

View File

@ -121,7 +121,9 @@ endif()
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_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
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 @@ endif()
# 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)

View File

@ -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()

View File

@ -178,6 +178,7 @@ endif()
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 @@ endif()
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 @@ endif()
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")