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)")
# Setup Source Code
#===============================================================================
-include_directories(include)
+add_subdirectory(include)
add_subdirectory(src)
--- /dev/null
+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()
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
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
-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()