[PATCH] D115535: [libunwind] Provide a way to conveniently install libunwind headers

Louis Dionne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 16 10:34:00 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c4867e6fc50: [libunwind] Provide a way to conveniently install libunwind headers (authored by rZhBoYao, committed by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115535/new/

https://reviews.llvm.org/D115535

Files:
  libunwind/CMakeLists.txt
  libunwind/include/CMakeLists.txt
  libunwind/src/CMakeLists.txt


Index: libunwind/src/CMakeLists.txt
===================================================================
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -133,7 +133,8 @@
   else()
     target_compile_options(unwind_shared PRIVATE -fno-rtti)
   endif()
-  target_link_libraries(unwind_shared PRIVATE ${LIBUNWIND_LIBRARIES})
+  target_link_libraries(unwind_shared PRIVATE ${LIBUNWIND_LIBRARIES}
+                                      PRIVATE unwind-headers)
   set_target_properties(unwind_shared
     PROPERTIES
       CXX_EXTENSIONS OFF
@@ -160,7 +161,8 @@
   else()
     target_compile_options(unwind_static PRIVATE -fno-rtti)
   endif()
-  target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES})
+  target_link_libraries(unwind_static PRIVATE ${LIBUNWIND_LIBRARIES}
+                                      PRIVATE unwind-headers)
   set_target_properties(unwind_static
     PROPERTIES
       CXX_EXTENSIONS OFF
@@ -207,4 +209,8 @@
             -DCMAKE_INSTALL_COMPONENT=unwind
             -DCMAKE_INSTALL_DO_STRIP=1
             -P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+  if(LIBUNWIND_INSTALL_HEADERS)
+    add_dependencies(install-unwind install-unwind-headers)
+    add_dependencies(install-unwind-stripped install-unwind-headers-stripped)
+  endif()
 endif()
Index: libunwind/include/CMakeLists.txt
===================================================================
--- /dev/null
+++ libunwind/include/CMakeLists.txt
@@ -0,0 +1,31 @@
+set(files
+    __libunwind_config.h
+    libunwind.h
+    mach-o/compact_unwind_encoding.h
+    unwind_arm_ehabi.h
+    unwind_itanium.h
+    unwind.h
+    )
+
+add_library(unwind-headers INTERFACE)
+target_include_directories(unwind-headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
+if(LIBUNWIND_INSTALL_HEADERS)
+  foreach(file ${files})
+    get_filename_component(dir ${file} DIRECTORY)
+    install(FILES ${file}
+      DESTINATION "include/${dir}"
+      COMPONENT unwind-headers
+      PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+    )
+  endforeach()
+
+  if(NOT CMAKE_CONFIGURATION_TYPES)
+    add_custom_target(install-unwind-headers
+      DEPENDS unwind-headers
+      COMMAND "${CMAKE_COMMAND}"
+              -DCMAKE_INSTALL_COMPONENT=unwind-headers
+              -P "${LIBUNWIND_BINARY_DIR}/cmake_install.cmake")
+    add_custom_target(install-unwind-headers-stripped DEPENDS install-unwind-headers)
+  endif()
+endif()
Index: libunwind/CMakeLists.txt
===================================================================
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -78,6 +78,7 @@
 option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
 option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. Requires locking dl_iterate_phdr." OFF)
 option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for .cfi_remember_state." OFF)
+option(LIBUNWIND_INSTALL_HEADERS "Install the libunwind headers." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
     "Define suffix of library directory name (32/64)")
@@ -372,7 +373,7 @@
 # Setup Source Code
 #===============================================================================
 
-include_directories(include)
+add_subdirectory(include)
 
 add_subdirectory(src)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115535.394921.patch
Type: text/x-patch
Size: 3308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211216/4323b2ea/attachment.bin>


More information about the llvm-commits mailing list