From: Michael Gottesman Date: Wed, 29 Jun 2016 21:59:14 +0000 (+0000) Subject: [cmake] Instead of just copying ClangConfig.cmake, configure it using ClangConfig... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e19e514672a6a94019fde624a35d9653dd957d2;p=clang [cmake] Instead of just copying ClangConfig.cmake, configure it using ClangConfig.cmake.in. This will allow for cmake to expand variables in ClangConfig.cmake for downstream users. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274176 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index f0af3e9da7..0bd630ffce 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -3,20 +3,24 @@ # the usual CMake convention seems to be ${Project}Targets.cmake. set(CLANG_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/clang) set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}") + get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS) export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake) -# Install a /lib/cmake/clang/ClangConfig.cmake file so that -# find_package(Clang) works. Install the target list with it. +# Generate ClangConfig.cmake for the build tree. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in + ${clang_cmake_builddir}/ClangConfig.cmake + @ONLY) + +# Generate ClangConfig.cmake for the install tree. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake + @ONLY) + install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}) - -# Also copy ClangConfig.cmake to the build directory so that dependent projects -# can build against a build directory of Clang more easily. -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake - ${clang_cmake_builddir}/ClangConfig.cmake - COPYONLY) diff --git a/cmake/modules/ClangConfig.cmake b/cmake/modules/ClangConfig.cmake.in similarity index 100% rename from cmake/modules/ClangConfig.cmake rename to cmake/modules/ClangConfig.cmake.in