diff --git a/CMakeLists.txt b/CMakeLists.txt index bb2c5b382..aa0c254b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.24") endif() include(cmake/project_version.cmake) include(cmake/SlsAddFlag.cmake) +include(cmake/SlsInstallExecutable.cmake) @@ -136,6 +137,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 installed executables and RPM package names" OFF) #Convenience option to switch off defaults when building Moench binaries only option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF) @@ -387,4 +389,43 @@ 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 +string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) +if(SLS_INSTALL_VERSIONED_BINARIES) + string(APPEND CPACK_RPM_PACKAGE_NAME "-${PROJECT_VERSION}") +endif() +set(CPACK_GENERATOR "RPM") +set(CPACK_RPM_FILE_NAME + "${PROJECT_NAME_LOWER}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm") +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_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) +# Keep the project version only once in filenames; RPM expands its metadata. +foreach(component IN LISTS CPACK_COMPONENTS_ALL) + string(TOUPPER "${component}" component_upper) + set(CPACK_RPM_${component_upper}_FILE_NAME + "${PROJECT_NAME_LOWER}-${component}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm") +endforeach() +include(CPack) diff --git a/RELEASE.txt b/RELEASE.txt index fb94c95cc..5afe35297 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -1,3 +1,13 @@ +Unreleased changes +================== + + * Added CPack RPM packaging for CLI, receiver, Moench tools and GUI. + SLS_INSTALL_VERSIONED_BINARIES=ON adds the project version to RPM + package names and all installed executable names, including the GUI, + Jungfrau tools and virtual detector servers, for side-by-side use. + RPM filenames include the project version only once. + + SLS Detector Package Minor Release 9.2.0 released on 02.06.2025 ================================================================== diff --git a/cmake/SlsInstallExecutable.cmake b/cmake/SlsInstallExecutable.cmake new file mode 100644 index 000000000..e8704d1ea --- /dev/null +++ b/cmake/SlsInstallExecutable.cmake @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2026 Contributors to the SLS Detector Package + +function(sls_install_executable target) + cmake_parse_arguments(ARG "" "DESTINATION;COMPONENT;EXPORT" "" ${ARGN}) + if(NOT ARG_DESTINATION) + set(ARG_DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif() + + set(install_args DESTINATION "${ARG_DESTINATION}") + if(ARG_COMPONENT) + list(APPEND install_args COMPONENT "${ARG_COMPONENT}") + endif() + + if(SLS_INSTALL_VERSIONED_BINARIES) + install(PROGRAMS "$" + ${install_args} + RENAME "$-${PROJECT_VERSION}${CMAKE_EXECUTABLE_SUFFIX}" + ) + else() + set(export_args) + if(ARG_EXPORT) + list(APPEND export_args EXPORT "${ARG_EXPORT}") + endif() + install(TARGETS ${target} + ${export_args} + RUNTIME ${install_args} + ) + endif() +endfunction() diff --git a/docs/src/installation.rst b/docs/src/installation.rst index 82128f9e5..db43deb26 100644 --- a/docs/src/installation.rst +++ b/docs/src/installation.rst @@ -217,6 +217,52 @@ Example cmake options Comment For v7.x.x of slsDetectorPackage and older, refer :ref:`zeromq notes for cmk script option to hint library location. ` +3.2.3. Build RPM packages +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +CPack builds separate RPMs for the command line tools (``cli``), receiver +executables (``receiver``), Moench processing tools (``zmq``), and GUI (``gui``). +Install ``rpm-build`` and the dependencies for the selected features, and build +on the target distribution or a matching container. + +For example, to package the command line tools, receiver and GUI: + +.. code-block:: bash + + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/usr -DSLS_USE_GUI=ON \ + -DSLS_INSTALL_VERSIONED_BINARIES=ON + cmake --build build -j4 + cpack --config build/CPackConfig.cmake -G RPM \ + -D 'CPACK_COMPONENTS_ALL=cli;receiver;gui' -B build + +Select only components enabled in the build. Add ``-DSLS_USE_MOENCH=ON`` and +the ``zmq`` component to package the Moench tools. + +``SLS_INSTALL_VERSIONED_BINARIES=ON`` includes the project version in the RPM +package names, for example ``slsdetectorpackage-9.2.0-cli`` and +``slsdetectorpackage-9.2.0-gui``. Installed executables also receive a version +suffix, such as ``sls_detector_get-9.2.0`` and ``slsDetectorGui-9.2.0``. This +allows RPMs for different project versions to be installed side by side. +RPM revisions of the same project version retain the same package names and +can be upgraded normally. + +RPM filenames include the version once, for example +``slsdetectorpackage-cli-9.2.0-1.fc44.x86_64.rpm``. The package's internal name +remains ``slsdetectorpackage-9.2.0-cli`` and its RPM version remains ``9.2.0``. + +The option also applies to Jungfrau processing tools and virtual detector +servers installed with ``cmake --install``. These are outside the current RPM +component selection. Executables in the build directory keep their original +names. With the option set to ``OFF`` (the default), installed executables and +RPM package names omit the project version. + +The RPM components contain executables; Python bindings, libraries and headers +are not included. A full ``cmake --install`` still installs libraries and +headers at their usual paths, so use separate prefixes for full installations +of different versions. + + 3.3. Build on old distributions using conda ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/slsDetectorCalibration/jungfrauExecutables/CMakeLists.txt b/slsDetectorCalibration/jungfrauExecutables/CMakeLists.txt index 08b32462a..f69a2c0a4 100644 --- a/slsDetectorCalibration/jungfrauExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/jungfrauExecutables/CMakeLists.txt @@ -95,7 +95,5 @@ foreach(exe ${JUNGFRAU_EXECUTABLES}) set_property(TARGET ${exe} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() - + sls_install_executable(${exe} DESTINATION bin) endforeach(exe ${JUNGFRAU_EXECUTABLES}) - -install(TARGETS ${JUNGFRAU_EXECUTABLES} DESTINATION bin) \ No newline at end of file diff --git a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt index 2faa1d852..be7898b66 100644 --- a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt @@ -84,7 +84,6 @@ foreach(exe ${MOENCH_EXECUTABLES}) set_property(TARGET ${exe} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() + sls_install_executable(${exe} DESTINATION bin COMPONENT zmq) endforeach(exe ${MOENCH_EXECUTABLES}) - -install(TARGETS ${MOENCH_EXECUTABLES} DESTINATION bin) \ No newline at end of file diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index e609e9aa7..b78ccdd95 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -119,11 +119,4 @@ if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET slsDetectorGui PROPERTY INTERPROCEDURAL_OPTIMIZATION True) 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} -) - +sls_install_executable(slsDetectorGui COMPONENT gui) diff --git a/slsDetectorServers/ctbDetectorServer/CMakeLists.txt b/slsDetectorServers/ctbDetectorServer/CMakeLists.txt index fd2cf796e..d6c07350b 100644 --- a/slsDetectorServers/ctbDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/ctbDetectorServer/CMakeLists.txt @@ -44,6 +44,4 @@ set_target_properties(ctbDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS ctbDetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(ctbDetectorServer_virtual) diff --git a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt index ddba9e4a4..6dc11a189 100644 --- a/slsDetectorServers/eigerDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/eigerDetectorServer/CMakeLists.txt @@ -37,9 +37,7 @@ set_target_properties(eigerDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS eigerDetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(eigerDetectorServer_virtual) configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY) diff --git a/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt b/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt index d7b0edb31..181a0e637 100644 --- a/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt +++ b/slsDetectorServers/gotthard2DetectorServer/CMakeLists.txt @@ -38,9 +38,7 @@ set_target_properties(gotthard2DetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS gotthard2DetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(gotthard2DetectorServer_virtual) configure_file(config_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard2.txt COPYONLY) configure_file(detid_gotthard2.txt ${CMAKE_BINARY_DIR}/bin/detid_gotthard2.txt COPYONLY) diff --git a/slsDetectorServers/gotthardDetectorServer/CMakeLists.txt b/slsDetectorServers/gotthardDetectorServer/CMakeLists.txt index 0ab9c9d1f..21c99d09e 100644 --- a/slsDetectorServers/gotthardDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/gotthardDetectorServer/CMakeLists.txt @@ -38,8 +38,6 @@ set_target_properties(gotthardDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS gotthardDetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(gotthardDetectorServer_virtual) -configure_file(config_gotthard.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard.txt COPYONLY) \ No newline at end of file +configure_file(config_gotthard.txt ${CMAKE_BINARY_DIR}/bin/config_gotthard.txt COPYONLY) diff --git a/slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt b/slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt index 4e042c931..ea1ff7f26 100644 --- a/slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt @@ -36,9 +36,8 @@ set_target_properties(jungfrauDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS jungfrauDetectorServer_virtual +sls_install_executable(jungfrauDetectorServer_virtual EXPORT "${TARGETS_EXPORT_NAME}" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) configure_file(config_jungfrau.txt ${CMAKE_BINARY_DIR}/bin/config_jungfrau.txt COPYONLY) diff --git a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt index 44a696aa6..55266ed03 100644 --- a/slsDetectorServers/moenchDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/moenchDetectorServer/CMakeLists.txt @@ -36,9 +36,8 @@ set_target_properties(moenchDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS moenchDetectorServer_virtual +sls_install_executable(moenchDetectorServer_virtual EXPORT "${TARGETS_EXPORT_NAME}" - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) configure_file(detid_moench.txt ${CMAKE_BINARY_DIR}/bin/detid_moench.txt COPYONLY) diff --git a/slsDetectorServers/mythen3DetectorServer/CMakeLists.txt b/slsDetectorServers/mythen3DetectorServer/CMakeLists.txt index ab1496fe6..e2ad52436 100644 --- a/slsDetectorServers/mythen3DetectorServer/CMakeLists.txt +++ b/slsDetectorServers/mythen3DetectorServer/CMakeLists.txt @@ -40,9 +40,7 @@ set_target_properties(mythen3DetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS mythen3DetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(mythen3DetectorServer_virtual) configure_file(DefaultPattern_mythen3.txt ${CMAKE_BINARY_DIR}/bin/DefaultPattern_mythen3.txt COPYONLY) configure_file(detid_mythen3.txt ${CMAKE_BINARY_DIR}/bin/detid_mythen3.txt COPYONLY) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt index 78a5fbfb7..9f8b0faf5 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt @@ -37,6 +37,4 @@ set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) -install(TARGETS xilinx_ctbDetectorServer_virtual - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -) +sls_install_executable(xilinx_ctbDetectorServer_virtual) diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index e61084330..38df9bdd6 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -111,8 +111,10 @@ if(SLS_USE_TEXTCLIENT) if((CMAKE_BUILD_TYPE STREQUAL "Release") AND SLS_LTO_AVAILABLE) set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True) endif() + + sls_install_executable(${val1} DESTINATION bin COMPONENT cli) endforeach() - install(TARGETS ${det_bin_names} DESTINATION bin) + endif(SLS_USE_TEXTCLIENT) diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 543ff7467..b7866176a 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -159,13 +159,21 @@ if (SLS_USE_RECEIVER_BINARIES) "$" ) - 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 ) + foreach(target IN LISTS SLS_RECEIVER_BINARIES) + sls_install_executable(${target} + EXPORT "${TARGETS_EXPORT_NAME}" + COMPONENT receiver + ) + endforeach() + + + endif(SLS_USE_RECEIVER_BINARIES)