Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

cmake: relax package compatibility constraints #1298

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions thrust/cmake/thrust-config-version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
alliepiper marked this conversation as resolved.
Show resolved Hide resolved
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)
alliepiper marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif()