[Offload] Add a proper install-offload target (#198206)

Summary:
This target is missing, it's the expected behavior for all LLVM
components to have a way to install them individually as components.
This allows us to selectively install offload versus other pieces of the
runtime. Also make this and the openmp handling canonical with libcxx.
This commit is contained in:
Joseph Huber 2026-05-18 08:26:00 -05:00 committed by GitHub
parent 48ab00842a
commit 499d0bb35f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 12 deletions

View file

@ -319,3 +319,17 @@ endif()
if(TARGET LLVMOffload)
add_dependencies(offload LLVMOffload)
endif()
add_custom_target(install-offload
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component offload)
add_custom_target(install-offload-stripped
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component offload --strip)
if(TARGET omptarget)
add_dependencies(install-offload omptarget)
add_dependencies(install-offload-stripped omptarget)
endif()
if(TARGET LLVMOffload)
add_dependencies(install-offload LLVMOffload)
add_dependencies(install-offload-stripped LLVMOffload)
endif()

View file

@ -43,7 +43,7 @@ set_target_properties(LLVMOffload PROPERTIES
POSITION_INDEPENDENT_CODE ON
INSTALL_RPATH "$ORIGIN"
BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
install(TARGETS LLVMOffload LIBRARY COMPONENT LLVMOffload DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
install(TARGETS LLVMOffload LIBRARY COMPONENT offload DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadAPI.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadPrint.hpp DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadAPI.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload COMPONENT offload)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/API/OffloadPrint.hpp DESTINATION ${CMAKE_INSTALL_PREFIX}/include/offload COMPONENT offload)

View file

@ -65,4 +65,4 @@ set_target_properties(omptarget PROPERTIES
POSITION_INDEPENDENT_CODE ON
INSTALL_RPATH "$ORIGIN"
BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
install(TARGETS omptarget LIBRARY COMPONENT omptarget DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")
install(TARGETS omptarget LIBRARY COMPONENT offload DESTINATION "${OFFLOAD_INSTALL_LIBDIR}")

View file

@ -151,14 +151,12 @@ add_custom_target(openmp ALL
COMMENT "OpenMP meta-target. Use 'ninja openmp' to build all OpenMP runtime targets."
)
if (NOT CMAKE_CONFIGURATION_TYPES)
add_custom_target(install-openmp
DEPENDS openmp
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component openmp)
add_custom_target(install-openmp-stripped
DEPENDS openmp
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component openmp --strip)
endif()
add_custom_target(install-openmp
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component openmp)
add_custom_target(install-openmp-stripped
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}" --component openmp --strip)
add_dependencies(install-openmp openmp)
add_dependencies(install-openmp-stripped openmp)
# Use the current compiler target to determine the appropriate runtime to build.
if("${LLVM_DEFAULT_TARGET_TRIPLE}" MATCHES "^amdgcn|^nvptx|^spirv64" OR