1 include(GNUInstallPackageDir)
3 include(FindPrefixFromConfig)
5 # Generate a list of CMake library targets so that other CMake projects can
6 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
7 # the usual CMake convention seems to be ${Project}Targets.cmake.
8 set(LLD_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/lld" CACHE STRING
9 "Path for CMake subdirectory for LLD (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/lld')")
10 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
11 set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/lld")
13 # Keep this in sync with llvm/cmake/CMakeLists.txt!
14 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
15 "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
16 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
17 string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
18 set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
20 get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
21 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
23 # Generate LLDConfig.cmake for the build tree.
24 set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
25 set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
26 set(LLD_CONFIG_INCLUDE_EXPORTS "include(\"${lld_cmake_builddir}/LLDTargets.cmake\")")
27 set(LLD_CONFIG_INCLUDE_DIRS
28 "${LLD_SOURCE_DIR}/include"
29 "${LLD_BINARY_DIR}/include"
32 ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
33 ${lld_cmake_builddir}/LLDConfig.cmake
36 ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfigVersion.cmake.in
37 ${lld_cmake_builddir}/LLDConfigVersion.cmake
39 set(LLD_CONFIG_CMAKE_DIR)
40 set(LLD_CONFIG_LLVM_CMAKE_DIR)
42 # Generate LLDConfig.cmake for the install tree.
43 find_prefix_from_config(LLD_CONFIG_CODE LLD_INSTALL_PREFIX "${LLD_INSTALL_PACKAGE_DIR}")
44 extend_path(LLD_CONFIG_CMAKE_DIR "\${LLD_INSTALL_PREFIX}" "${LLD_INSTALL_PACKAGE_DIR}")
45 extend_path(LLD_CONFIG_LLVM_CMAKE_DIR "\${LLD_INSTALL_PREFIX}" "${LLVM_INSTALL_PACKAGE_DIR}")
46 get_config_exports_includes(LLD LLD_CONFIG_INCLUDE_EXPORTS)
47 extend_path(LLD_CONFIG_INCLUDE_DIRS "\${LLD_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
49 ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
50 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
53 ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfigVersion.cmake.in
54 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfigVersion.cmake
57 set(LLD_CONFIG_CMAKE_DIR)
59 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
60 install_distribution_exports(LLD)
63 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
64 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfigVersion.cmake
65 DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
66 COMPONENT lld-cmake-exports)
68 if(NOT LLVM_ENABLE_IDE)
69 # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
70 add_custom_target(lld-cmake-exports)
71 add_llvm_install_targets(install-lld-cmake-exports
72 COMPONENT lld-cmake-exports)