[libcxx-commits] [libcxx] 6dfdf79 - [libc++abi] Install the libc++abi headers from libc++abi

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 28 14:24:26 PST 2022


Author: Louis Dionne
Date: 2022-02-28T17:22:53-05:00
New Revision: 6dfdf79b8c482c892a76406799d285baf5d71198

URL: https://github.com/llvm/llvm-project/commit/6dfdf79b8c482c892a76406799d285baf5d71198
DIFF: https://github.com/llvm/llvm-project/commit/6dfdf79b8c482c892a76406799d285baf5d71198.diff

LOG: [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

Added: 
    libcxxabi/include/CMakeLists.txt

Modified: 
    libcxx/utils/ci/apple-install-libcxx.sh
    libcxxabi/CMakeLists.txt
    libcxxabi/src/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/ci/apple-install-libcxx.sh b/libcxx/utils/ci/apple-install-libcxx.sh
index a0e8874a0302..7fdb225873d7 100755
--- a/libcxx/utils/ci/apple-install-libcxx.sh
+++ b/libcxx/utils/ci/apple-install-libcxx.sh
@@ -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

diff  --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index 73cab7d13f8e..ebda5a4fb624 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -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)

diff  --git a/libcxxabi/include/CMakeLists.txt b/libcxxabi/include/CMakeLists.txt
new file mode 100644
index 000000000000..0deb7b1eb9e7
--- /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
index 762649a965ca..d1c6ad89f74b 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -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")


        


More information about the libcxx-commits mailing list