[LLD][COFF] Fix TypeServerSource matcher with more than one collision
[llvm-project.git] / lld / cmake / modules / CMakeLists.txt
blob760c9d5f8d87dafb88402be30be624b0bcb27a93
1 include(ExtendPath)
2 include(FindPrefixFromConfig)
4 # Generate a list of CMake library targets so that other CMake projects can
5 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
6 # the usual CMake convention seems to be ${Project}Targets.cmake.
7 set(LLD_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/lld)
8 set(lld_cmake_builddir "${CMAKE_BINARY_DIR}/${LLD_INSTALL_PACKAGE_DIR}")
10 # Keep this in sync with llvm/cmake/CMakeLists.txt!
11 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
12 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
14 get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
15 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
17 # Generate LLDConfig.cmake for the build tree.
18 set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
19 set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
20 set(LLD_CONFIG_INCLUDE_EXPORTS "include(\"${lld_cmake_builddir}/LLDTargets.cmake\")")
21 set(LLD_CONFIG_INCLUDE_DIRS
22   "${LLD_SOURCE_DIR}/include"
23   "${LLD_BINARY_DIR}/include"
24   )
25 configure_file(
26   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
27   ${lld_cmake_builddir}/LLDConfig.cmake
28   @ONLY)
29 set(LLD_CONFIG_CMAKE_DIR)
30 set(LLD_CONFIG_LLVM_CMAKE_DIR)
32 # Generate LLDConfig.cmake for the install tree.
33 find_prefix_from_config(LLD_CONFIG_CODE LLD_INSTALL_PREFIX "${LLD_INSTALL_PACKAGE_DIR}")
34 set(LLD_CONFIG_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLD_INSTALL_PACKAGE_DIR}")
35 set(LLD_CONFIG_LLVM_CMAKE_DIR "\${LLD_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
36 get_config_exports_includes(LLD LLD_CONFIG_INCLUDE_EXPORTS)
37 extend_path(LLD_CONFIG_INCLUDE_DIRS "\${LLD_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")
38 configure_file(
39   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
40   ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
41   @ONLY)
42 set(LLD_CONFIG_CODE)
43 set(LLD_CONFIG_CMAKE_DIR)
45 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
46   install_distribution_exports(LLD)
48   install(FILES
49     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
50     DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
51     COMPONENT lld-cmake-exports)
53   if(NOT LLVM_ENABLE_IDE)
54     # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
55     add_custom_target(lld-cmake-exports)
56     add_llvm_install_targets(install-lld-cmake-exports
57                              COMPONENT lld-cmake-exports)
58   endif()
59 endif()