]> granicus.if.org Git - clang/commitdiff
[cmake] Instead of just copying ClangConfig.cmake, configure it using ClangConfig...
authorMichael Gottesman <mgottesman@apple.com>
Wed, 29 Jun 2016 21:59:14 +0000 (21:59 +0000)
committerMichael Gottesman <mgottesman@apple.com>
Wed, 29 Jun 2016 21:59:14 +0000 (21:59 +0000)
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

cmake/modules/CMakeLists.txt
cmake/modules/ClangConfig.cmake.in [moved from cmake/modules/ClangConfig.cmake with 100% similarity]

index f0af3e9da71790b4096a500a81e34cc6a7acc3fe..0bd630ffceb177d66ab3b8b9f73512c1db371b0e 100644 (file)
@@ -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 <prefix>/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)