aboutsummaryrefslogtreecommitdiff
path: root/polly
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2022-11-17 23:35:18 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2022-11-25 21:57:58 +0000
commitecfa2d3d9943a48411d04a4b3103c42b4653d9af (patch)
treec89ebf87f5b1c22d4a81060f4db8c5704712dbcc /polly
parent234d2e27db2ed4b958e31fe7db10941e6ce1b84e (diff)
downloadllvm-ecfa2d3d9943a48411d04a4b3103c42b4653d9af.zip
llvm-ecfa2d3d9943a48411d04a4b3103c42b4653d9af.tar.gz
llvm-ecfa2d3d9943a48411d04a4b3103c42b4653d9af.tar.bz2
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
Diffstat (limited to 'polly')
-rw-r--r--polly/cmake/CMakeLists.txt9
-rw-r--r--polly/cmake/PollyConfig.cmake.in3
-rw-r--r--polly/cmake/PollyConfigVersion.cmake.in13
3 files changed, 24 insertions, 1 deletions
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()