Skip to content

[lld] enable installing lld headers and libraries as part of distribution #127123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions lld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@ include_directories(BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/include
)

if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING
PATTERN "*.h"
)
endif()

add_subdirectory(Common)
add_subdirectory(tools/lld)

Expand All @@ -207,4 +199,41 @@ add_subdirectory(MachO)
add_subdirectory(MinGW)
add_subdirectory(wasm)

add_custom_target(lld-headers)
set_target_properties(lld-headers PROPERTIES FOLDER "Misc")
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/lld
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT lld-headers
FILES_MATCHING
PATTERN "*.h"
)

if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-lld-headers
DEPENDS lld-headers
COMPONENT lld-headers)
endif()
endif()

# Custom target to install all lld libraries
add_custom_target(lld-libraries)
if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-lld-libraries
DEPENDS lld-libraries
COMPONENT lld-libraries)
endif()

get_property(LLD_LIBS GLOBAL PROPERTY LLD_ALL_LIBS)
if(LLD_LIBS)
list(REMOVE_DUPLICATES LLD_LIBS)
foreach(lib ${LLD_LIBS})
add_dependencies(lld-libraries ${lib})
if(NOT LLVM_ENABLE_IDE)
add_dependencies(install-lld-libraries install-${lib})
add_dependencies(install-lld-libraries-stripped install-${lib}-stripped)
endif()
endforeach()
endif()

add_subdirectory(cmake/modules)
5 changes: 3 additions & 2 deletions lld/cmake/modules/AddLLD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ macro(add_lld_library name)
llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})

if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
get_target_export_arg(${name} LLD export_to_lldtargets)
get_target_export_arg(${name} LLD export_to_lldtargets UMBRELLA lld-libraries)
install(TARGETS ${name}
COMPONENT ${name}
${export_to_lldtargets}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
set_property(GLOBAL APPEND PROPERTY LLD_ALL_LIBS ${name})
set_property(GLOBAL APPEND PROPERTY LLD_EXPORTS ${name})
endif()
endmacro(add_lld_library)
Expand Down