Files
Jungfraujoch/viewer/CMakeLists.txt
T
leonarski_fandClaude Opus 5 0003acf2e4 packaging: name the Debian broker package jfjoch, and let its DKMS scripts run
CPACK_DEBIAN_MAIN_COMPONENT does not exist. Only CPackRPM.cmake has a MAIN_COMPONENT
variable, which is why the RPM came out as "jfjoch" while the .deb of the same component
came out as "jfjoch-jfjoch" - the DEB generator names every component package
"<CPACK_PACKAGE_NAME>-<component>" unless CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME overrides
it, and the line we set was read by nobody. It also named a component ("broker") that
does not exist, so it could not have matched anything either way. Set the name the
generator actually reads, and declare Replaces/Conflicts on the old one: the new package
owns the same files, so dpkg would otherwise refuse to unpack it over an installation
that already has jfjoch-jfjoch.

The DKMS component's postinst and prerm are the driver's postinstall.sh and
preuninstall.sh, configure_file'd into place. They were mode 644, and
CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION is off, so they were packaged as they are
- and dpkg cannot execute a maintainer script it cannot execute. The RPM path is
unaffected: it reads the same files as text into the spec.

The viewer's Freedesktop menu entry and its icon are installed on Linux only now. On
Windows the Start Menu shortcut comes from CPACK_PACKAGE_EXECUTABLES and on macOS from
the .app bundle, so on those two the installer was carrying a share/applications entry
and a share/pixmaps icon that nothing reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 20:51:55 +02:00

222 lines
9.9 KiB
CMake

# SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
# SPDX-License-Identifier: GPL-3.0-only
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
# D-Bus (single-instance / remote control) is Linux-only: Qt6::DBus does not
# exist on Windows or macOS. Default ON on Linux, OFF elsewhere.
IF(UNIX AND NOT APPLE)
OPTION(JFJOCH_VIEWER_DBUS "Build viewer with D-Bus support (Linux only)" ON)
ELSE()
OPTION(JFJOCH_VIEWER_DBUS "Build viewer with D-Bus support (Linux only)" OFF)
ENDIF()
SET(JFJOCH_VIEWER_QT_COMPONENTS Core Gui Widgets Charts Concurrent OpenGL OpenGLWidgets)
IF(JFJOCH_VIEWER_DBUS)
LIST(APPEND JFJOCH_VIEWER_QT_COMPONENTS DBus)
ENDIF()
FIND_PACKAGE(Qt6 COMPONENTS ${JFJOCH_VIEWER_QT_COMPONENTS} REQUIRED)
QT_ADD_RESOURCES(APP_RESOURCES resources/resources.qrc)
ADD_EXECUTABLE(jfjoch_viewer jfjoch_viewer.cpp JFJochViewerWindow.cpp JFJochViewerWindow.h
JFJochViewerMenu.cpp
JFJochViewerMenu.h
image_viewer/JFJochDiffractionImage.cpp
image_viewer/JFJochDiffractionImage.h
image_viewer/JFJochSimpleImage.cpp
image_viewer/JFJochSimpleImage.h
JFJochImageReadingWorker.cpp
JFJochImageReadingWorker.h
JFJochHttpReader.cpp
JFJochHttpReader.h
RunData.h
JFJochProcessController.cpp
JFJochProcessController.h
JFJochViewerDatasetInfo.cpp
JFJochViewerDatasetInfo.h
JFJochViewerSidePanel.cpp
JFJochViewerSidePanel.h
widgets/TitleLabel.cpp
widgets/TitleLabel.h
charts/JFJochDatasetInfoChartView.cpp
charts/JFJochDatasetInfoChartView.h
widgets/JFJochViewerImageStatistics.cpp
widgets/JFJochViewerImageStatistics.h
charts/JFJochSimpleChartView.cpp
charts/JFJochSimpleChartView.h
JFJochViewerStatusBar.cpp
JFJochViewerStatusBar.h
windows/JFJochViewerImageListWindow.cpp
windows/JFJochViewerImageListWindow.h
widgets/NumericComboBox.cpp
widgets/NumericComboBox.h
windows/JFJochViewerMetadataWindow.cpp
windows/JFJochViewerMetadataWindow.h
windows/JFJochMergeStatsWindow.cpp
windows/JFJochMergeStatsWindow.h
widgets/NumberLineEdit.cpp
widgets/NumberLineEdit.h
widgets/SliderPlusBox.cpp
widgets/SliderPlusBox.h
widgets/JFJochViewerSidePanelChart.cpp
widgets/JFJochViewerSidePanelChart.h
widgets/JFJochViewerSettingsDock.cpp
widgets/JFJochViewerSettingsDock.h
widgets/CollapsibleSection.cpp
widgets/CollapsibleSection.h
widgets/ToolbarIcons.cpp
widgets/ToolbarIcons.h
widgets/JFJochViewerImageStrip.cpp
widgets/JFJochViewerImageStrip.h
windows/JFJochViewerSpotListWindow.cpp
windows/JFJochViewerSpotListWindow.h
image_viewer/JFJochAzIntImage.cpp
image_viewer/JFJochAzIntImage.h
windows/JFJochViewerReflectionListWindow.cpp
windows/JFJochViewerReflectionListWindow.h
toolbar/JFJochViewerToolbarImage.cpp
toolbar/JFJochViewerToolbarImage.h
toolbar/JFJochViewerToolbarDisplay.cpp
toolbar/JFJochViewerToolbarDisplay.h
SimpleImage.h
windows/JFJochCalibrationWindow.cpp
windows/JFJochCalibrationWindow.h
windows/JFJochHelperWindow.cpp
windows/JFJochHelperWindow.h
windows/JFJochLicenseWindow.cpp
windows/JFJochLicenseWindow.h
image_viewer/JFJochImage.cpp
image_viewer/JFJochImage.h
image_viewer/JFJochFollowerImage.cpp
image_viewer/JFJochFollowerImage.h
windows/JFJoch2DAzintImageWindow.cpp
windows/JFJoch2DAzintImageWindow.h
widgets/JFJochViewerROIResult.cpp
widgets/JFJochViewerROIResult.h
widgets/JFJochViewerROIList.cpp
widgets/JFJochViewerROIList.h
widgets/ResolutionRingWidget.cpp
widgets/ResolutionRingWidget.h
image_viewer/JFJochGridScanImage.cpp
image_viewer/JFJochGridScanImage.h
widgets/PowderCalibrationWidget.cpp
widgets/PowderCalibrationWidget.h
${APP_RESOURCES}
windows/JFJochViewerReciprocalSpaceWindow.cpp
windows/JFJochViewerReciprocalSpaceWindow.h
windows/JFJochMagnifierWindow.cpp
windows/JFJochMagnifierWindow.h
windows/JFJochProcessingJobsWindow.cpp
windows/JFJochProcessingJobsWindow.h
)
TARGET_LINK_LIBRARIES(jfjoch_viewer Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Charts Qt6::Concurrent
Qt6::OpenGL Qt6::OpenGLWidgets
JFJochReader JFJochLogger JFJochCommon JFJochWriter JFJochImageAnalysis Rugnux
fftw3f libcurl_static) # vendored static libcurl by concrete name, not the CURL::libcurl
# alias, which a system libcurl can shadow (see top-level CMakeLists)
# Native GUI app per platform: a .app bundle on macOS, GUI subsystem (no console window) on
# Windows. Each property is ignored on the platforms it does not apply to, so set both always.
SET_TARGET_PROPERTIES(jfjoch_viewer PROPERTIES
MACOSX_BUNDLE ON
WIN32_EXECUTABLE ON)
# Application icon: embedded into the .exe via a Windows resource script, and copied into
# the macOS .app bundle (referenced from Info.plist through MACOSX_BUNDLE_ICON_FILE).
IF(WIN32)
TARGET_SOURCES(jfjoch_viewer PRIVATE resources/jfjoch.rc)
ELSEIF(APPLE)
SET(_viewer_icns ${CMAKE_CURRENT_SOURCE_DIR}/resources/jfjoch.icns)
TARGET_SOURCES(jfjoch_viewer PRIVATE ${_viewer_icns})
SET_SOURCE_FILES_PROPERTIES(${_viewer_icns} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
SET_TARGET_PROPERTIES(jfjoch_viewer PROPERTIES MACOSX_BUNDLE_ICON_FILE jfjoch.icns)
ENDIF()
INSTALL(TARGETS jfjoch_viewer
BUNDLE DESTINATION . COMPONENT viewer # macOS .app bundle
RUNTIME DESTINATION bin COMPONENT viewer) # Windows .exe / Linux binary
IF(JFJOCH_VIEWER_DBUS)
TARGET_SOURCES(jfjoch_viewer PRIVATE dbus/JFJochViewerAdaptor.cpp dbus/JFJochViewerAdaptor.h)
TARGET_LINK_LIBRARIES(jfjoch_viewer Qt6::DBus)
TARGET_COMPILE_DEFINITIONS(jfjoch_viewer PRIVATE JFJOCH_VIEWER_DBUS)
INSTALL(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/dbus/ch.psi.jfjoch_viewer.service
DESTINATION share/dbus-1/services
COMPONENT viewer
)
ENDIF()
# Freedesktop menu entry and its icon: Linux only. On Windows the Start Menu shortcut comes from
# CPACK_PACKAGE_EXECUTABLES and on macOS from the .app bundle, so shipping these there would only
# put two dead files into the installer.
IF(UNIX AND NOT APPLE)
INSTALL(
FILES resources/jfjoch.png
DESTINATION share/pixmaps
COMPONENT viewer
)
INSTALL(
FILES jfjoch_viewer.desktop
DESTINATION share/applications
COMPONENT viewer
)
ENDIF()
# Platform integration plugin: XCB on Linux, native plugin on Windows/macOS.
IF(WIN32)
qt_import_plugins(jfjoch_viewer INCLUDE Qt::QWindowsIntegrationPlugin)
ELSEIF(APPLE)
qt_import_plugins(jfjoch_viewer INCLUDE Qt::QCocoaIntegrationPlugin)
ELSE()
qt_import_plugins(jfjoch_viewer INCLUDE Qt::QXcbIntegrationPlugin)
ENDIF()
# Bundle the Qt runtime into the install tree at install time: this drives windeployqt on Windows
# and macdeployqt on macOS, copying the Qt shared libraries + plugins next to the app. With a
# static Qt (e.g. our Linux build) there is nothing to copy, so it is a no-op. Requires Qt >= 6.5,
# which is when the OUTPUT_SCRIPT signature and the Linux deploy path landed (6.3/6.4 used the older
# FILENAME_VARIABLE and had no Linux support); skipped on older Qt. NO_UNSUPPORTED_PLATFORM_ERROR
# keeps it from hard-failing on configurations it does not handle.
IF(Qt6_VERSION VERSION_GREATER_EQUAL "6.5")
qt_generate_deploy_app_script(
TARGET jfjoch_viewer
OUTPUT_SCRIPT jfjoch_viewer_deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR)
INSTALL(SCRIPT ${jfjoch_viewer_deploy_script} COMPONENT viewer)
ENDIF()
# Bundle the cuFFT runtime next to the viewer so the installed app runs on hosts that have an NVIDIA
# driver but no CUDA toolkit. cuFFT is the ONLY CUDA component we link dynamically (cudart and the
# fast-feedback indexer are static), so it is the one runtime file the toolkit would otherwise have to
# provide; it is self-contained (Windows: depends only on KERNEL32; Linux: only libc/libstdc++ and the
# always-present driver libcuda). GPU build only. macOS has no CUDA, so it is excluded.
IF(JFJOCH_CUDA_AVAILABLE)
IF(WIN32)
# CUDA 13 keeps redistributable DLLs in bin/x64, earlier toolkits in bin -- glob both.
FILE(GLOB _cufft_dll
"${CUDAToolkit_BIN_DIR}/x64/cufft64_*.dll"
"${CUDAToolkit_BIN_DIR}/cufft64_*.dll")
IF(NOT _cufft_dll)
MESSAGE(FATAL_ERROR "cuFFT runtime DLL not found under ${CUDAToolkit_BIN_DIR}")
ENDIF()
INSTALL(FILES ${_cufft_dll} DESTINATION bin COMPONENT viewer)
ELSEIF(UNIX AND NOT APPLE AND JFJOCH_VIEWER_ONLY)
# Only the self-contained Linux .tar.gz (JFJOCH_VIEWER_ONLY) bundles cuFFT: it has no package
# manager, so it must carry its runtime deps, and we want that set really minimal. The .deb/.rpm
# builds deliberately do NOT bundle it - CUDA there is centrally managed by the distro's packages.
# Ship libcufft.so beside the binary and add an $ORIGIN rpath so the loader finds the bundled copy
# (the same self-contained-app idea as the Windows DLL). CUDA::cufft is an UNKNOWN imported target,
# so install its file directly, resolving the symlink chain (libcufft.so -> .so.<major> -> real
# file) so the libcufft.so.<major> the binary is linked against lands in bin.
INSTALL(CODE
"file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/bin\" TYPE SHARED_LIBRARY FOLLOW_SYMLINK_CHAIN FILES \"${CUDA_cufft_LIBRARY}\")"
COMPONENT viewer)
SET_TARGET_PROPERTIES(jfjoch_viewer PROPERTIES INSTALL_RPATH "$ORIGIN")
ENDIF()
ENDIF()