brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 9ad2f98 Raw
95 lines · plain
1include(GNUInstallPackageDir)2include(ExtendPath)3include(LLVMDistributionSupport)4include(FindPrefixFromConfig)5 6# Generate a list of CMake library targets so that other CMake projects can7# link against them. LLVM calls its version of this file LLVMExports.cmake, but8# the usual CMake convention seems to be ${Project}Targets.cmake.9set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING10  "Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')")11 12# Keep this in sync with llvm/cmake/CMakeLists.txt!13set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING14  "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")15# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.16string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_builddir "${LLVM_LIBRARY_DIR}")17set(llvm_cmake_builddir "${llvm_builddir}/cmake/llvm")18if(CLANG_BUILT_STANDALONE)19  # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.20  set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")21else()22  set(clang_cmake_builddir "${llvm_builddir}/cmake/clang")23endif()24 25get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)26export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)27 28# Generate ClangConfig.cmake for the build tree.29set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")30set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")31set(CLANG_CONFIG_INCLUDE_EXPORTS "include(\"${clang_cmake_builddir}/ClangTargets.cmake\")")32set(CLANG_CONFIG_INCLUDE_DIRS33  "${CLANG_SOURCE_DIR}/include"34  "${CLANG_BINARY_DIR}/include"35  )36configure_file(37  ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in38  ${clang_cmake_builddir}/ClangConfig.cmake39  @ONLY)40configure_file(41  ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfigVersion.cmake.in42  ${clang_cmake_builddir}/ClangConfigVersion.cmake43  @ONLY)44set(CLANG_CONFIG_CMAKE_DIR)45set(CLANG_CONFIG_LLVM_CMAKE_DIR)46 47# For compatibility with projects that include(ClangConfig)48# via CMAKE_MODULE_PATH, place API modules next to it.49# Copy without source permissions because the source could be read-only,50# but we need to write into the copied folder.51file(COPY .52  DESTINATION ${clang_cmake_builddir}53  NO_SOURCE_PERMISSIONS54  FILES_MATCHING PATTERN *.cmake55  PATTERN CMakeFiles EXCLUDE56  )57 58# Generate ClangConfig.cmake for the install tree.59find_prefix_from_config(CLANG_CONFIG_CODE CLANG_INSTALL_PREFIX "${CLANG_INSTALL_PACKAGE_DIR}")60extend_path(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}" "${CLANG_INSTALL_PACKAGE_DIR}")61extend_path(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}" "${LLVM_INSTALL_PACKAGE_DIR}")62get_config_exports_includes(Clang CLANG_CONFIG_INCLUDE_EXPORTS)63extend_path(base_includedir "\${CLANG_INSTALL_PREFIX}" "${CMAKE_INSTALL_INCLUDEDIR}")64set(CLANG_CONFIG_INCLUDE_DIRS65  "${base_includedir}"66  )67configure_file(68  ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in69  ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake70  @ONLY)71configure_file(72  ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfigVersion.cmake.in73  ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfigVersion.cmake74  @ONLY)75set(CLANG_CONFIG_CODE)76set(CLANG_CONFIG_CMAKE_DIR)77 78if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)79  install_distribution_exports(Clang)80 81  install(FILES82    ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake83    ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfigVersion.cmake84    ${CMAKE_CURRENT_SOURCE_DIR}/AddClang.cmake85    DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}86    COMPONENT clang-cmake-exports)87 88  if(NOT LLVM_ENABLE_IDE)89    # Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS90    add_custom_target(clang-cmake-exports)91    add_llvm_install_targets(install-clang-cmake-exports92                             COMPONENT clang-cmake-exports)93  endif()94endif()95