From fde0021356f29259fa39a4a9e8f350d5a2dc1dab Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sat, 26 Sep 2020 21:41:35 -0400 Subject: [PATCH 1/2] cmake: relax package compatibility constraints This relaxes the compatibility constraints to what cmake calls "SameMajorVersion", ie., the version found must be >= than the version requested, and major has to match exactly. This essentially uses the same code as cmake's `write_basic_package_version_file()`. --- thrust/cmake/thrust-config-version.cmake | 30 ++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/thrust/cmake/thrust-config-version.cmake b/thrust/cmake/thrust-config-version.cmake index 0d7fdb943..b88255fda 100644 --- a/thrust/cmake/thrust-config-version.cmake +++ b/thrust/cmake/thrust-config-version.cmake @@ -10,24 +10,20 @@ math(EXPR THRUST_VERSION_MAJOR "${THRUST_VERSION_FLAT} / 100000") math(EXPR THRUST_VERSION_MINOR "(${THRUST_VERSION_FLAT} / 100) % 1000") math(EXPR THRUST_VERSION_PATCH "${THRUST_VERSION_FLAT} % 100") # Thrust: "subminor" CMake: "patch" -# Build comparison versions: -set(THRUST_COMPAT "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}") -set(THRUST_EXACT "${THRUST_COMPAT}.${THRUST_VERSION_TWEAK}") -set(FIND_COMPAT "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}.${PACKAGE_FIND_VERSION_PATCH}") -set(FIND_EXACT "${FIND_COMPAT}.${PACKAGE_FIND_VERSION_TWEAK}") +set(THRUST_VERSION "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}.${THRUST_VERSION_TWEAK}") -# Set default results -set(PACKAGE_VERSION ${THRUST_EXACT}) -set(PACKAGE_VERSION_UNSUITABLE FALSE) -set(PACKAGE_VERSION_COMPATIBLE FALSE) -set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION ${THRUST_VERSION}) -# Test for compatibility (ignores tweak) -if (FIND_COMPAT VERSION_EQUAL THRUST_COMPAT) - set(PACKAGE_VERSION_COMPATIBLE TRUE) -endif() +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL THRUST_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() -# Test for exact (does not ignore tweak) -if (FIND_EXACT VERSION_EQUAL THRUST_EXACT) - set(PACKAGE_VERSION_EXACT TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() endif() From 6104ed3eb002fe5297cf3a495afad6506865921e Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Mon, 28 Sep 2020 13:11:28 -0400 Subject: [PATCH 2/2] cmake/version: explicitly set defaults for returned variables --- thrust/cmake/thrust-config-version.cmake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/thrust/cmake/thrust-config-version.cmake b/thrust/cmake/thrust-config-version.cmake index b88255fda..a5cad0ad6 100644 --- a/thrust/cmake/thrust-config-version.cmake +++ b/thrust/cmake/thrust-config-version.cmake @@ -13,14 +13,13 @@ math(EXPR THRUST_VERSION_PATCH "${THRUST_VERSION_FLAT} % 100") # Thrust: "submin set(THRUST_VERSION "${THRUST_VERSION_MAJOR}.${THRUST_VERSION_MINOR}.${THRUST_VERSION_PATCH}.${THRUST_VERSION_TWEAK}") set(PACKAGE_VERSION ${THRUST_VERSION}) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_UNSUITABLE FALSE) -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() +if(PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION) if(PACKAGE_FIND_VERSION_MAJOR STREQUAL THRUST_VERSION_MAJOR) set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) endif() if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)