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()`.
MODIFY
thrust/cmake/thrust-config-version.cmake
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)
+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)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
+endif()

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()`.