forked from OSchip/llvm-project
[ClangConfig] Instead of hard coding the ClangTargets location to /ClangTargets.cmake, follow LLVM's example and use a pre-computed cmake variable @CLANG_CONFIG_EXPORTS_FILE@.
This just makes ClangConfig more consistent with LLVMConfig. llvm-svn: 274178
This commit is contained in:
parent
1b87cd3974
commit
497e97ffe3
|
@ -8,12 +8,26 @@ get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
|
|||
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
|
||||
|
||||
# Generate ClangConfig.cmake for the build tree.
|
||||
set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
|
||||
set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
|
||||
${clang_cmake_builddir}/ClangConfig.cmake
|
||||
@ONLY)
|
||||
|
||||
# Generate ClangConfig.cmake for the install tree.
|
||||
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)
|
||||
set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INSTALL_PREFIX}/\${CLANG_INSTALL_PACKAGE_DIR}")
|
||||
set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
|
||||
|
|
|
@ -6,5 +6,9 @@
|
|||
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
|
||||
@CLANG_CONFIG_CODE@
|
||||
|
||||
set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
|
||||
|
||||
# Provide all our library targets to users.
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ClangTargets.cmake")
|
||||
include("@CLANG_CONFIG_EXPORTS_FILE@")
|
||||
|
|
Loading…
Reference in New Issue