mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
cmake: Adjust the UHD_VERSION check to work with cmake 4.1
UHD_VERSION needs to be also checked against an empty string since cmake 4.1 sets this variable during project setup, also if it was undefined before. Furthermore we need to backup and restore custom UHD_VERSION when defined for e.g. by using option -DUHD_VERSION=<version>, because project() setup will reset the version to an empty string.
This commit is contained in:
parent
aa0c47877d
commit
9018f578b2
@ -31,7 +31,22 @@ set(UHD_RELEASE_MODE "${UHD_RELEASE_MODE}" CACHE STRING "UHD Release Mode")
|
||||
########################################################################
|
||||
# Project setup
|
||||
########################################################################
|
||||
# Backup custom UHD_VERSION if defined by using option -DUHD_VERSION=...,
|
||||
# because project() will reset it to an empty string.
|
||||
if(UHD_VERSION)
|
||||
set(CUSTOM_UHD_VERSION "${UHD_VERSION}")
|
||||
endif(UHD_VERSION)
|
||||
|
||||
# Note: if UHD_VERSION is not defined, project() will leave it undefined
|
||||
# for cmake version < 4.1.0, but set it to an empty string for cmake
|
||||
# version >= 4.1.0.
|
||||
project(UHD CXX C)
|
||||
|
||||
# Restore the custom UHD_VERSION if it was defined before project()
|
||||
if(DEFINED CUSTOM_UHD_VERSION)
|
||||
set(UHD_VERSION "${CUSTOM_UHD_VERSION}" CACHE STRING "" FORCE)
|
||||
endif(DEFINED CUSTOM_UHD_VERSION)
|
||||
|
||||
enable_testing()
|
||||
|
||||
# Make sure our local CMake Modules path comes first
|
||||
|
||||
@ -160,7 +160,7 @@ endif()
|
||||
|
||||
########################################################################
|
||||
# Define the derived version variables:
|
||||
if(DEFINED UHD_VERSION)
|
||||
if(UHD_VERSION)
|
||||
set(UHD_VERSION "${UHD_VERSION}" CACHE STRING "Set UHD_VERSION to a custom value")
|
||||
elseif(TRIM_UHD_VERSION STREQUAL "True")
|
||||
set(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}.${UHD_VERSION_PATCH}-${UHD_GIT_HASH}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user