2021-12-30 14:22:48 +08:00
|
|
|
include(ExtendPath)
|
2022-01-03 10:25:06 +08:00
|
|
|
include(FindPrefixFromConfig)
|
2021-12-30 14:22:48 +08:00
|
|
|
|
2020-05-03 06:32:40 +08:00
|
|
|
# Generate a list of CMake library targets so that other CMake projects can
|
|
|
|
# link against them. LLVM calls its version of this file LLVMExports.cmake, but
|
|
|
|
# the usual CMake convention seems to be ${Project}Targets.cmake.
|
|
|
|
set(LLD_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/lld)
|
|
|
|
set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/${LLD_INSTALL_PACKAGE_DIR}")
|
|
|
|
|
|
|
|
# Keep this in sync with llvm/cmake/CMakeLists.txt!
|
|
|
|
set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
|
|
|
|
set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
|
|
|
|
|
|
|
|
get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
|
|
|
|
export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
|
|
|
|
|
|
|
|
# Generate LLDConfig.cmake for the build tree.
|
|
|
|
set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
|
|
|
|
set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
|
2020-10-02 05:35:28 +08:00
|
|
|
set(LLD_CONFIG_INCLUDE_EXPORTS "include(\"${lld_cmake_builddir}/LLDTargets.cmake\")")
|
2020-05-03 06:32:40 +08:00
|
|
|
set(LLD_CONFIG_INCLUDE_DIRS
|
|
|
|
"${LLD_SOURCE_DIR}/include"
|
|
|
|
"${LLD_BINARY_DIR}/include"
|
|
|
|
)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
|
|
|
|
${lld_cmake_builddir}/LLDConfig.cmake
|
|
|
|
@ONLY)
|
|
|
|
set(LLD_CONFIG_CMAKE_DIR)
|
|
|
|
set(LLD_CONFIG_LLVM_CMAKE_DIR)
|
|
|
|
|
|
|
|
# Generate LLDConfig.cmake for the install tree.
|
2022-01-03 10:25:06 +08:00
|
|
|
find_prefix_from_config(LLD_CONFIG_CODE LLD_INSTALL_PREFIX "${LLD_INSTALL_PACKAGE_DIR}")
|
2020-05-03 06:32:40 +08:00
|
|
|
set(LLD_CONFIG_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLD_INSTALL_PACKAGE_DIR}")
|
|
|
|
set(LLD_CONFIG_LLVM_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
2020-10-02 05:35:28 +08:00
|
|
|
get_config_exports_includes(LLD LLD_CONFIG_INCLUDE_EXPORTS)
|
2021-12-30 14:22:48 +08:00
|
|
|
extend_path(LLD_CONFIG_INCLUDE_DIRS "\${LLD_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
2020-05-03 06:32:40 +08:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
|
|
|
|
@ONLY)
|
|
|
|
set(LLD_CONFIG_CODE)
|
|
|
|
set(LLD_CONFIG_CMAKE_DIR)
|
|
|
|
|
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
2020-10-02 05:35:28 +08:00
|
|
|
install_distribution_exports(LLD)
|
2020-05-03 06:32:40 +08:00
|
|
|
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
|
|
|
|
DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
|
|
|
|
COMPONENT lld-cmake-exports)
|
|
|
|
|
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
|
|
|
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
|
|
|
|
add_custom_target(lld-cmake-exports)
|
|
|
|
add_llvm_install_targets(install-lld-cmake-exports
|
|
|
|
COMPONENT lld-cmake-exports)
|
|
|
|
endif()
|
|
|
|
endif()
|