aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattprost <matt.prost@ni.com>2022-04-29 14:47:09 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2022-06-10 13:24:04 -0500
commit72e6df51de5a766889fedcb9970dedd7fcfda6e8 (patch)
treed16c5a7d1b27710e740775752293c12b62e77ab3
parentcb8fa61a5bcc576224ab8afa80ed712c31ddd629 (diff)
downloaduhd-72e6df51de5a766889fedcb9970dedd7fcfda6e8.tar.gz
uhd-72e6df51de5a766889fedcb9970dedd7fcfda6e8.tar.bz2
uhd-72e6df51de5a766889fedcb9970dedd7fcfda6e8.zip
cmake: Add support for fedora rpm versioning
Adds cmake option for replacing dashes in the UHD Component version with underscores. This is necessary as Fedora package management is now enforcing the format <Package>-<Version>-<Release> for all rpm builds, so dashes in the UHD_VERSION from dev branches is not supported. Signed-off-by: mattprost <matt.prost@ni.com>
-rw-r--r--host/CMakeLists.txt1
-rw-r--r--host/cmake/Modules/UHDPackage.cmake34
-rw-r--r--host/cmake/Modules/UHDVersion.cmake5
3 files changed, 24 insertions, 16 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt
index 3a523ad5d..99dd17fe7 100644
--- a/host/CMakeLists.txt
+++ b/host/CMakeLists.txt
@@ -98,6 +98,7 @@ endif()
# Packaging Variables
########################################################################
+option(UNDERSCORE_UHD_VERSION "Replace dashes in uhd version with underscores" OFF)
set(LIBUHD_PKG ${LIBUHD_PKG} CACHE BOOL "Build Debian libuhd003 package")
set(LIBUHDDEV_PKG ${LIBUHDDEV_PKG} CACHE BOOL "Build Debian libuhd-dev package")
set(UHDHOST_PKG ${UHDPOST_PKG} CACHE BOOL "Build Debian uhd-host package")
diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake
index f02bd3ca1..ce9f04be7 100644
--- a/host/cmake/Modules/UHDPackage.cmake
+++ b/host/cmake/Modules/UHDPackage.cmake
@@ -40,22 +40,23 @@ endif()
# Setup package file name
########################################################################
if(REDHAT)
- find_program(LSB_RELEASE_EXECUTABLE lsb_release)
-
- if(LSB_RELEASE_EXECUTABLE)
- #extract system information by executing the commands
- execute_process(
- COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id
- OUTPUT_VARIABLE LSB_ID OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- execute_process(
- COMMAND ${LSB_RELEASE_EXECUTABLE} --short --release
- OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE
- )
-
- #set a more sensible package name for this system
- set(CPACK_PACKAGE_FILE_NAME "uhd_${UHD_VERSION}_${LSB_ID}-${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "")
- endif(LSB_RELEASE_EXECUTABLE)
+ #extract system information by executing the commands
+ execute_process(
+ COMMAND bash -c "source /etc/os-release && echo $ID"
+ OUTPUT_VARIABLE OS_ID OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ execute_process(
+ COMMAND bash -c "source /etc/os-release && echo $VERSION_ID"
+ OUTPUT_VARIABLE VERSION_ID OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+
+ #set a more sensible package name for this system
+ if(UHD_RELEASE_MODE)
+ string(REGEX REPLACE "(.release)$" "" uhd_vers_pretty ${UHD_VERSION})
+ set(CPACK_PACKAGE_FILE_NAME "uhd-${uhd_vers_pretty}-${OS_ID}${VERSION_ID}" CACHE INTERNAL "")
+ else()
+ set(CPACK_PACKAGE_FILE_NAME "uhd-${UHD_VERSION}-${OS_ID}${VERSION_ID}" CACHE INTERNAL "")
+ endif()
endif(REDHAT)
if(${CPACK_GENERATOR} STREQUAL NSIS)
@@ -152,6 +153,7 @@ set(CPACK_COMPONENTS_ALL libraries pythonapi headers utilities examples manual d
set(CPACK_RPM_SPEC_MORE_DEFINE "%global __python %{__python3}")
set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, python3-requests")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/man;/usr/share/man/man1;/usr/lib64/pkgconfig;/usr/lib64/cmake;/usr/lib64/python2.7;/usr/lib64/python2.7/site-packages")
+set(CPACK_RPM_FILE_NAME "$CACHE{CPACK_PACKAGE_FILE_NAME}.rpm")
foreach(filename post_install post_uninstall pre_install pre_uninstall)
string(TOUPPER ${filename} filename_upper)
list(APPEND CPACK_RPM_${filename_upper}_SCRIPT_FILE ${UHD_BINARY_DIR}/redhat/${filename})
diff --git a/host/cmake/Modules/UHDVersion.cmake b/host/cmake/Modules/UHDVersion.cmake
index 2261bf357..6854ff4a9 100644
--- a/host/cmake/Modules/UHDVersion.cmake
+++ b/host/cmake/Modules/UHDVersion.cmake
@@ -148,4 +148,9 @@ else()
set(UHD_ABI_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_API}.${UHD_VERSION_ABI}")
endif()
+if(UNDERSCORE_UHD_VERSION)
+ string(REPLACE "-" "_" _uhd_version $CACHE{UHD_VERSION})
+ set(UHD_VERSION "${_uhd_version}" CACHE STRING "" FORCE)
+endif()
+
set(UHD_COMPONENT "UHD")