r274178 - [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 at .

Michael Gottesman via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 14:59:19 PDT 2016


Author: mgottesman
Date: Wed Jun 29 16:59:19 2016
New Revision: 274178

URL: http://llvm.org/viewvc/llvm-project?rev=274178&view=rev
Log:
[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 at .

This just makes ClangConfig more consistent with LLVMConfig.

Modified:
    cfe/trunk/cmake/modules/CMakeLists.txt
    cfe/trunk/cmake/modules/ClangConfig.cmake.in

Modified: cfe/trunk/cmake/modules/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/CMakeLists.txt?rev=274178&r1=274177&r2=274178&view=diff
==============================================================================
--- cfe/trunk/cmake/modules/CMakeLists.txt (original)
+++ cfe/trunk/cmake/modules/CMakeLists.txt Wed Jun 29 16:59:19 2016
@@ -8,12 +8,26 @@ get_property(CLANG_EXPORTS GLOBAL PROPER
 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

Modified: cfe/trunk/cmake/modules/ClangConfig.cmake.in
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ClangConfig.cmake.in?rev=274178&r1=274177&r2=274178&view=diff
==============================================================================
--- cfe/trunk/cmake/modules/ClangConfig.cmake.in (original)
+++ cfe/trunk/cmake/modules/ClangConfig.cmake.in Wed Jun 29 16:59:19 2016
@@ -6,5 +6,9 @@
 
 find_package(LLVM REQUIRED CONFIG)
 
+ at 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@")




More information about the cfe-commits mailing list