2016-06-30 04:22:44 +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(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang)
|
2018-01-25 03:26:50 +08:00
|
|
|
set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
|
2016-06-30 05:59:14 +08:00
|
|
|
|
2017-01-31 22:15:40 +08:00
|
|
|
# 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}")
|
|
|
|
|
2016-06-30 04:22:44 +08:00
|
|
|
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
|
|
|
|
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
|
|
|
|
|
2016-06-30 05:59:14 +08:00
|
|
|
# Generate ClangConfig.cmake for the build tree.
|
2016-06-30 05:59:19 +08:00
|
|
|
set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
|
2017-01-31 22:15:40 +08:00
|
|
|
set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
|
2016-06-30 05:59:19 +08:00
|
|
|
set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
|
2017-02-07 02:17:23 +08:00
|
|
|
set(CLANG_CONFIG_INCLUDE_DIRS
|
|
|
|
"${CLANG_SOURCE_DIR}/include"
|
|
|
|
"${CLANG_BINARY_DIR}/include"
|
|
|
|
)
|
2016-06-30 05:59:14 +08:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
|
|
|
|
${clang_cmake_builddir}/ClangConfig.cmake
|
|
|
|
@ONLY)
|
2016-06-30 05:59:20 +08:00
|
|
|
set(CLANG_CONFIG_CMAKE_DIR)
|
2017-01-31 22:15:40 +08:00
|
|
|
set(CLANG_CONFIG_LLVM_CMAKE_DIR)
|
2016-06-30 05:59:20 +08:00
|
|
|
set(CLANG_CONFIG_EXPORTS_FILE)
|
2016-06-30 05:59:14 +08:00
|
|
|
|
|
|
|
# Generate ClangConfig.cmake for the install tree.
|
2016-06-30 05:59:19 +08:00
|
|
|
set(CLANG_CONFIG_CODE "
|
|
|
|
# Compute the installation prefix from this LLVMConfig.cmake file location.
|
|
|
|
get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
|
|
|
|
# Construct the proper number of get_filename_component(... PATH)
|
|
|
|
# calls to compute the installation prefix.
|
|
|
|
string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
|
|
|
|
foreach(p ${_count})
|
|
|
|
set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
|
|
|
|
get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" PATH)")
|
|
|
|
endforeach(p)
|
2016-06-30 05:59:23 +08:00
|
|
|
set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
|
2017-01-31 22:15:40 +08:00
|
|
|
set(CLANG_CONFIG_LLVM_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
|
2016-06-30 05:59:19 +08:00
|
|
|
set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
|
2017-02-07 02:17:23 +08:00
|
|
|
set(CLANG_CONFIG_INCLUDE_DIRS
|
2017-03-22 03:17:53 +08:00
|
|
|
"\${CLANG_INSTALL_PREFIX}/include"
|
2017-02-07 02:17:23 +08:00
|
|
|
)
|
2016-06-30 05:59:14 +08:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
|
|
|
|
@ONLY)
|
2016-06-30 05:59:20 +08:00
|
|
|
set(CLANG_CONFIG_CODE)
|
|
|
|
set(CLANG_CONFIG_CMAKE_DIR)
|
|
|
|
set(CLANG_CONFIG_EXPORTS_FILE)
|
2016-06-30 05:59:14 +08:00
|
|
|
|
2016-06-30 05:59:15 +08:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
2016-11-08 13:02:33 +08:00
|
|
|
get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
|
|
|
|
if(clang_has_exports)
|
2019-02-21 07:16:15 +08:00
|
|
|
install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
|
|
|
|
COMPONENT clang-cmake-exports)
|
2016-11-08 13:02:33 +08:00
|
|
|
endif()
|
2016-06-30 04:22:44 +08:00
|
|
|
|
2016-06-30 05:59:15 +08:00
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
|
2019-02-21 07:16:15 +08:00
|
|
|
DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
|
|
|
|
COMPONENT clang-cmake-exports)
|
|
|
|
|
|
|
|
if(NOT LLVM_ENABLE_IDE)
|
|
|
|
# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
|
|
|
|
add_custom_target(clang-cmake-exports)
|
|
|
|
add_llvm_install_targets(install-clang-cmake-exports
|
|
|
|
COMPONENT clang-cmake-exports)
|
|
|
|
endif()
|
2016-06-30 05:59:15 +08:00
|
|
|
endif()
|