From ecfa2d3d9943a48411d04a4b3103c42b4653d9af Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 17 Nov 2022 23:35:18 +0000 Subject: Add version to all LLVM cmake package Add a version to non-LLVM cmake package so that users needing an exact version match can use the version parameter to find_package. Also adjust the find_package(LLVM) to use an exact version match as well. Reviewed By: arsenm, stellaraccident, mceier Differential Revision: https://reviews.llvm.org/D138274 --- polly/cmake/CMakeLists.txt | 9 +++++++++ polly/cmake/PollyConfig.cmake.in | 3 ++- polly/cmake/PollyConfigVersion.cmake.in | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 polly/cmake/PollyConfigVersion.cmake.in (limited to 'polly') diff --git a/polly/cmake/CMakeLists.txt b/polly/cmake/CMakeLists.txt index 1834107..d7b3fa1 100644 --- a/polly/cmake/CMakeLists.txt +++ b/polly/cmake/CMakeLists.txt @@ -82,6 +82,10 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in ${polly_cmake_builddir}/PollyConfig.cmake @ONLY) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfigVersion.cmake.in + ${polly_cmake_builddir}/PollyConfigVersion.cmake + @ONLY) file(GENERATE OUTPUT ${polly_cmake_builddir}/${POLLY_EXPORTS_FILE_NAME} @@ -138,6 +142,10 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake @ONLY) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfigVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake + @ONLY) file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME} CONTENT "${POLLY_EXPORTS}") @@ -146,6 +154,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${POLLY_EXPORTS_FILE_NAME}" DESTINATION "${POLLY_INSTALL_PACKAGE_DIR}") endif () diff --git a/polly/cmake/PollyConfig.cmake.in b/polly/cmake/PollyConfig.cmake.in index ce1144d..4513ec4 100644 --- a/polly/cmake/PollyConfig.cmake.in +++ b/polly/cmake/PollyConfig.cmake.in @@ -2,7 +2,8 @@ @POLLY_CONFIG_CODE@ -find_package(LLVM REQUIRED CONFIG +set(LLVM_VERSION @LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@.@LLVM_VERSION_PATCH@) +find_package(LLVM ${LLVM_VERSION} EXACT REQUIRED CONFIG HINTS "@POLLY_CONFIG_LLVM_CMAKE_DIR@") set(Polly_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) diff --git a/polly/cmake/PollyConfigVersion.cmake.in b/polly/cmake/PollyConfigVersion.cmake.in new file mode 100644 index 0000000..e9ac4ed --- /dev/null +++ b/polly/cmake/PollyConfigVersion.cmake.in @@ -0,0 +1,13 @@ +set(PACKAGE_VERSION "@PACKAGE_VERSION@") + +# LLVM is API-compatible only with matching major.minor versions +# and patch versions not less than that requested. +if("@LLVM_VERSION_MAJOR@.@LLVM_VERSION_MINOR@" VERSION_EQUAL + "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}" + AND NOT "@LLVM_VERSION_PATCH@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}") + set(PACKAGE_VERSION_COMPATIBLE 1) + if("@LLVM_VERSION_PATCH@" VERSION_EQUAL + "${PACKAGE_FIND_VERSION_PATCH}") + set(PACKAGE_VERSION_EXACT 1) + endif() +endif() -- cgit v1.1