From 753ef2be45755739ce9a623005f8625f53a0d6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=B6jdh?= Date: Mon, 4 May 2026 17:56:23 +0200 Subject: [PATCH] Add support for building RPMs (#1439) * rpm * versioned binaries * also zmq process * use distro style naming * added gui --- CMakeLists.txt | 32 ++++++++++++++++++- .../moenchExecutables/CMakeLists.txt | 14 +++++++- slsDetectorGui/CMakeLists.txt | 5 +-- slsDetectorSoftware/CMakeLists.txt | 16 +++++++++- slsReceiverSoftware/CMakeLists.txt | 30 +++++++++++++---- 5 files changed, 84 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 042b28905..cb9645225 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,7 @@ option(SLS_TUNE_LOCAL "tune to local machine" OFF) option(SLS_DEVEL_HEADERS "install headers for devel" OFF) option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF) option(SLS_USE_JUNGFRAU "compile post processing for Jungfrau" OFF) +option(SLS_INSTALL_VERSIONED_BINARIES "Add version number to binaries on install" OFF) #Needed for multi version RPM #Convenience option to switch off defaults when building Moench binaries only option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF) @@ -463,4 +464,33 @@ if(SLS_MASTER_PROJECT) set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}") set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared) include(cmake/package_config.cmake) -endif() \ No newline at end of file +endif() + + + +#Packaging +# Generic CPack metadata +set(CPACK_PACKAGE_NAME "slsDetectorPackage") +set(CPACK_PACKAGE_VENDOR "Paul Scherrer Institut") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "DAQ software for PSI developed detectors") + +# RPM-specific settings +set(CPACK_GENERATOR "RPM") +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_PACKAGE_LICENSE "LGPL-3.0") +set(CPACK_RPM_PACKAGE_GROUP "Applications/System") +set(CPACK_RPM_PACKAGE_RELEASE 1) +# Adds %{?dist} to the RPM Release field +set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) +set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") +set(CPACK_RPM_COMPONENT_INSTALL ON) + + +set(CPACK_RPM_GUI_PACKAGE_REQUIRES + "qt5-qtbase, qt5-qtbase-gui" +) + +#control which RPMs are generated +set(CPACK_COMPONENTS_ALL cli receiver zmq gui) +include(CPack) \ No newline at end of file diff --git a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt index abb220e20..44b212df3 100644 --- a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt @@ -84,7 +84,19 @@ foreach(exe ${MOENCH_EXECUTABLES}) set_property(TARGET ${exe} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() + # Mainly for RPMs to enable side by side installations of different versions + if(SLS_INSTALL_VERSIONED_BINARIES) + install(PROGRAMS "$" + DESTINATION bin + RENAME "$-${PROJECT_VERSION}" + COMPONENT zmq + ) + else() + install(TARGETS ${exe} + DESTINATION bin + COMPONENT zmq + ) + endif() endforeach(exe ${MOENCH_EXECUTABLES}) -install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin) diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index e609e9aa7..992bfe3ef 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -121,9 +121,6 @@ endif() install(TARGETS slsDetectorGui # EXPORT "${TARGETS_EXPORT_NAME}" #do not export gui - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - # PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT gui ) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 04f30d27f..472205230 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -108,8 +108,22 @@ if(SLS_USE_TEXTCLIENT) if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() + + # Mainly for RPMs to enable side by side installations of different versions + if(SLS_INSTALL_VERSIONED_BINARIES) + install(PROGRAMS "$" + DESTINATION bin + RENAME "$-${PROJECT_VERSION}" + COMPONENT cli + ) + else() + install(TARGETS ${val1} + DESTINATION bin + COMPONENT cli + ) + endif() endforeach() - install(TARGETS ${det_bin_names} DESTINATION bin) + endif(SLS_USE_TEXTCLIENT) diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 7fbd78ffd..be56105b5 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -167,13 +167,31 @@ if (SLS_USE_RECEIVER_BINARIES) target_link_libraries(slsFrameSynchronizer PRIVATE "$") endif() - install(TARGETS slsReceiver slsMultiReceiver slsFrameSynchronizer - EXPORT "${TARGETS_EXPORT_NAME}" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sls + # Receiver binaries + set(SLS_RECEIVER_BINARIES + slsReceiver + slsMultiReceiver + slsFrameSynchronizer ) + if(SLS_INSTALL_VERSIONED_BINARIES) + message(STATUS "Versioned binaries will be installed") + foreach(target IN LISTS SLS_RECEIVER_BINARIES) + install(PROGRAMS "$" + DESTINATION ${CMAKE_INSTALL_BINDIR} + RENAME "$-${PROJECT_VERSION}" + COMPONENT receiver + ) + endforeach() + else() + install(TARGETS ${SLS_RECEIVER_BINARIES} + EXPORT "${TARGETS_EXPORT_NAME}" + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT receiver + ) + endif() + + + endif(SLS_USE_RECEIVER_BINARIES)