alexreinking updated this revision to Diff 333683.
alexreinking added a comment.

Drop *ConfigVersion.cmake files from `CMakeFiles` tree


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97513/new/

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===================================================================
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -67,10 +67,17 @@
 
 # PollyConfig holds the target definitions and general settings, PollyExports
 # the imported locations
+include(CMakePackageConfigHelpers)
+
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
   ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 
 file(GENERATE
   OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
@@ -128,6 +135,7 @@
   install(
     FILES
     "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake"
+    "${POLLY_CONFIG_CMAKE_DIR}/PollyConfigVersion.cmake"
     "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}"
     DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}")
 endif ()
Index: polly/CMakeLists.txt
===================================================================
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -5,6 +5,7 @@
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LLVM_CMAKE_DIR})
   include(HandleLLVMOptions)
   include(AddLLVM)
@@ -48,6 +49,14 @@
 set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
 
+# Compute the Polly version from the LLVM version.
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" POLLY_VERSION ${PACKAGE_VERSION})
+message(STATUS "Polly version: ${POLLY_VERSION}")
+
+set(POLLY_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(POLLY_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(POLLY_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
+
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   ${CMAKE_MODULE_PATH}
Index: mlir/cmake/modules/CMakeLists.txt
===================================================================
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -17,6 +17,8 @@
 get_property(MLIR_TRANSLATION_LIBS GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
 # Generate MlirConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(MLIR_CONFIG_CMAKE_DIR "${mlir_cmake_builddir}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(MLIR_CONFIG_EXPORTS_FILE "\${MLIR_CMAKE_DIR}/MLIRTargets.cmake")
@@ -28,6 +30,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/MLIRConfig.cmake.in
   ${mlir_cmake_builddir}/MLIRConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${mlir_cmake_builddir}/MLIRConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(MLIR_CONFIG_CMAKE_DIR)
 set(MLIR_CONFIG_LLVM_CMAKE_DIR)
 set(MLIR_CONFIG_EXPORTS_FILE)
@@ -80,6 +87,7 @@
 
   install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake
+    ${mlir_cmake_builddir}/MLIRConfigVersion.cmake
     ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake
     DESTINATION ${MLIR_INSTALL_PACKAGE_DIR}
     COMPONENT mlir-cmake-exports)
Index: mlir/CMakeLists.txt
===================================================================
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -23,6 +23,8 @@
   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
     "${CMAKE_CURRENT_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+
+  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
 endif()
 
 set(MLIR_MAIN_SRC_DIR     ${CMAKE_CURRENT_SOURCE_DIR}  )
@@ -33,6 +35,14 @@
 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 set(MLIR_TOOLS_DIR   ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
+# Compute the MLIR version from the LLVM version.
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" MLIR_VERSION ${PACKAGE_VERSION})
+message(STATUS "MLIR version: ${MLIR_VERSION}")
+
+set(MLIR_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(MLIR_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(MLIR_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
+
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
 include(AddMLIR)
Index: lld/cmake/modules/CMakeLists.txt
===================================================================
--- lld/cmake/modules/CMakeLists.txt
+++ lld/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)
 
 # Generate LLDConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(LLD_CONFIG_CMAKE_DIR "${lld_cmake_builddir}")
 set(LLD_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(LLD_CONFIG_EXPORTS_FILE "${lld_cmake_builddir}/LLDTargets.cmake")
@@ -23,6 +25,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/LLDConfig.cmake.in
   ${lld_cmake_builddir}/LLDConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${lld_cmake_builddir}/LLDConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(LLD_CONFIG_CMAKE_DIR)
 set(LLD_CONFIG_LLVM_CMAKE_DIR)
 set(LLD_CONFIG_EXPORTS_FILE)
@@ -59,6 +66,7 @@
 
   install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLDConfig.cmake
+    ${lld_cmake_builddir}/LLDConfigVersion.cmake
     DESTINATION ${LLD_INSTALL_PACKAGE_DIR}
     COMPONENT lld-cmake-exports)
 
Index: lld/CMakeLists.txt
===================================================================
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -123,14 +123,13 @@
 endif()
 
 # Compute the LLD version from the LLVM version.
-string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLD_VERSION
+string(REGEX MATCH "([0-9]+)\\.([0-9]+)(\\.([0-9]+))?" LLD_VERSION
   ${PACKAGE_VERSION})
 message(STATUS "LLD version: ${LLD_VERSION}")
 
-string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" LLD_VERSION_MAJOR
-  ${LLD_VERSION})
-string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" LLD_VERSION_MINOR
-  ${LLD_VERSION})
+set(LLD_VERSION_MAJOR "${CMAKE_MATCH_1}")
+set(LLD_VERSION_MINOR "${CMAKE_MATCH_2}")
+set(LLD_VERSION_PATCH "${CMAKE_MATCH_4}")  # Using 4 instead of 3 skips the dot before the patch number.
 
 # Configure the Version.inc file.
 configure_file(
Index: flang/cmake/modules/CMakeLists.txt
===================================================================
--- flang/cmake/modules/CMakeLists.txt
+++ flang/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${FLANG_EXPORTS} FILE ${flang_cmake_builddir}/FlangTargets.cmake)
 
 # Generate FlangConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(FLANG_CONFIG_CMAKE_DIR "${flang_cmake_builddir}")
 set(FLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(FLANG_CONFIG_EXPORTS_FILE "${flang_cmake_builddir}/FlangTargets.cmake")
@@ -23,6 +25,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/FlangConfig.cmake.in
   ${flang_cmake_builddir}/FlangConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${flang_cmake_builddir}/FlangConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(FLANG_CONFIG_CMAKE_DIR)
 set(FLANG_CONFIG_LLVM_CMAKE_DIR)
 set(FLANG_CONFIG_EXPORTS_FILE)
@@ -62,6 +69,7 @@
 
   install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/FlangConfig.cmake
+    ${flang_cmake_builddir}/FlangConfigVersion.cmake
     DESTINATION ${FLANG_INSTALL_PACKAGE_DIR}
     COMPONENT flang-cmake-exports)
 
Index: clang/cmake/modules/CMakeLists.txt
===================================================================
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -12,6 +12,8 @@
 export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
 
 # Generate ClangConfig.cmake for the build tree.
+include(CMakePackageConfigHelpers)
+
 set(CLANG_CONFIG_CMAKE_DIR "${clang_cmake_builddir}")
 set(CLANG_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
 set(CLANG_CONFIG_EXPORTS_FILE "${clang_cmake_builddir}/ClangTargets.cmake")
@@ -23,6 +25,11 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in
   ${clang_cmake_builddir}/ClangConfig.cmake
   @ONLY)
+write_basic_package_version_file(
+  "${clang_cmake_builddir}/ClangConfigVersion.cmake"
+  VERSION "${PACKAGE_VERSION}"
+  COMPATIBILITY SameMinorVersion
+)
 set(CLANG_CONFIG_CMAKE_DIR)
 set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 set(CLANG_CONFIG_EXPORTS_FILE)
@@ -61,6 +68,7 @@
 
   install(FILES
     ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
+    ${clang_cmake_builddir}/ClangConfigVersion.cmake
     ${CMAKE_CURRENT_SOURCE_DIR}/AddClang.cmake
     DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
     COMPONENT clang-cmake-exports)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to