Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
fail-fast: false
matrix:
runs-on: ["ubuntu-latest"]
qt-major-version: [5, 6]
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2

Expand All @@ -36,7 +37,8 @@ jobs:
- name: Retrieve new lists of APT packages
run: sudo apt-get update

- name: Install Qt
- name: Install Qt 5
if: ${{ matrix.qt-major-version == 5 }}
run: |
sudo apt-get install -y \
qtbase5-dev \
Expand All @@ -50,17 +52,33 @@ jobs:
libqt5x11extras5-dev \
libxt-dev

- name: Install VTK
if: matrix.runs-on == 'ubuntu-latest'
- name: Install VTK (Qt 5)
if: ${{ matrix.runs-on == 'ubuntu-latest' && matrix.qt-major-version == 5 }}
run: |
sudo apt-get install -y \
libvtk9-dev \
libvtk9-qt-dev

- name: Install Qt 6
if: ${{ matrix.qt-major-version == 6 }}
run: |
sudo apt-get install -y \
qt6-base-dev \
qt6-base-private-dev \
qt6-5compat-dev \
qt6-multimedia-dev \
qt6-scxml-dev \
qt6-tools-dev \
qt6-tools-dev-tools \
qt6-svg-dev \
qt6-webengine-dev \
libqt6openglwidgets6 \
libxt-dev

- name: Configure CTK
run: |
cmake \
-DCTK_QT_VERSION:STRING=5 \
-DCTK_QT_VERSION:STRING=${{ matrix.qt-major-version }} \
-DCTK_ENABLE_Widgets:BOOL=ON \
-DCTK_USE_SYSTEM_VTK:BOOL=$CTK_USE_VTK \
-DCTK_LIB_Visualization/VTK/Widgets:BOOL=$CTK_USE_VTK \
Expand All @@ -81,11 +99,14 @@ jobs:
-B CTK-build \
-S .
env:
CTK_USE_VTK: "${{ matrix.runs-on == 'ubuntu-latest' && 'ON' || 'OFF' }}"
CTK_USE_VTK: "${{ matrix.runs-on == 'ubuntu-latest' && matrix.qt-major-version == 5 && 'ON' || 'OFF' }}"

- name: Display Qt5_DIR
- name: Display Qt_DIR
run: |
cat CTK-build/CMakeCache.txt | grep ^Qt5_DIR
echo "Qt5_DIR:"
cat CTK-build/CMakeCache.txt | grep '^Qt5_DIR' || true
echo "Qt6_DIR:"
cat CTK-build/CMakeCache.txt | grep '^Qt6_DIR' || true

- name: Build CTK
run: |
Expand Down
4 changes: 2 additions & 2 deletions CMake/ctkFunctionGeneratePluginManifest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ function(ctkFunctionGeneratePluginManifest MANIFEST_QRC_FILEPATH_VAR)
if(MY_SKIP_QT5_ADD_RESOURCES)
set(${MANIFEST_QRC_FILEPATH_VAR} ${_manifest_qrc_filepath} PARENT_SCOPE)
else()
if(CTK_QT_VERSION VERSION_EQUAL "5")
QT5_ADD_RESOURCES(_qrc_src ${_manifest_qrc_filepath})
if(CTK_QT_VERSION MATCHES "^(5|6)$")
qt_add_resources(_qrc_src ${_manifest_qrc_filepath})
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
endif()
Expand Down
4 changes: 2 additions & 2 deletions CMake/ctkMacroBuildPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ macro(ctkMacroBuildPlugin)
if(MY_TRANSLATIONS)
set_source_files_properties(${MY_TRANSLATIONS}
PROPERTIES OUTPUT_LOCATION ${_translations_dir})
if(CTK_QT_VERSION VERSION_EQUAL "5")
qt5_create_translation(_plugin_qm_files ${MY_SRCS} ${MY_UI_FORMS} ${MY_TRANSLATIONS})
if(CTK_QT_VERSION MATCHES "^(5|6)$")
qt_create_translation(_plugin_qm_files ${MY_SRCS} ${MY_UI_FORMS} ${MY_TRANSLATIONS})
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
endif()
Expand Down
30 changes: 17 additions & 13 deletions CMake/ctkMacroBuildQtPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ macro(ctkMacroBuildQtPlugin)
set(compile_flags "-DQT_PLUGIN")
if(CTK_QT_VERSION VERSION_EQUAL "5")
set(compile_flags "${compile_flags} -DHAVE_QT5")
elseif(CTK_QT_VERSION VERSION_EQUAL "6")
set(compile_flags "${compile_flags} -DHAVE_QT6")
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
endif()
Expand Down Expand Up @@ -172,27 +174,29 @@ macro(ctkMacroBuildQtPlugin)
endmacro()

macro(ctkMacroBuildQtDesignerPlugin)
find_package(Qt${CTK_QT_VERSION} COMPONENTS Designer REQUIRED)
if(CTK_QT_VERSION VERSION_EQUAL "5")
find_package(Qt5 COMPONENTS Designer REQUIRED)
# Variables like Qt*_DEFINITIONS may include generator expressions (genex) in newer Qt versions,
# which cannot be directly passed to "add_definitions()". For example, the list may include elements
# like "$<$<BOOL:$<TARGET_PROPERTY:QT_PLUGIN_CLASS_NAME>>:QDESIGNER_EXPORT_WIDGETS>". Stripping these using
# "string(GENEX_STRIP ...)" would result in an incomplete set of definitions.
# Therefore, we maintain the use of add_definitions()/include_directories() for Qt5 and encourage
# developers to rely on target usage requirements for newer versions.
add_definitions(${Qt5Designer_DEFINITIONS})
include_directories(${Qt5Designer_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
# For newer Qt versions, use target usage requirements to handle definitions and include directories.
endif()
ctkMacroBuildQtPlugin(
PLUGIN_DIR designer
${ARGN})
if(CTK_QT_VERSION VERSION_EQUAL "5")
cmake_parse_arguments(MY
"" # no options
"NAME;EXPORT_DIRECTIVE;FOLDER;PLUGIN_DIR" # one value args
"SRCS;MOC_SRCS;UI_FORMS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES;RESOURCES" # multi value args
${ARGN}
)
target_link_libraries(${MY_NAME} Qt5::Designer)
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
endif()
cmake_parse_arguments(MY
"" # no options
"NAME;EXPORT_DIRECTIVE;FOLDER;PLUGIN_DIR" # one value args
"SRCS;MOC_SRCS;UI_FORMS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES;RESOURCES" # multi value args
${ARGN}
)
target_link_libraries(${MY_NAME} Qt${CTK_QT_VERSION}::Designer)
endmacro()

macro(ctkMacroBuildQtIconEnginesPlugin)
Expand Down
10 changes: 5 additions & 5 deletions CMake/ctkMacroSetupPlugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ macro(ctkMacroSetupPlugins )

# Set the variable QT_INSTALLED_LIBRARY_DIR that contains all
# Qt shared libraries
if(CTK_QT_VERSION VERSION_EQUAL "5")
if(CTK_QT_VERSION MATCHES "^(5|6)$")
if(WIN32)
get_target_property(_qt5_moc_executable Qt5::moc LOCATION)
get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt5_moc_executable} PATH)
get_target_property(_qt_moc_executable Qt${CTK_QT_VERSION}::moc LOCATION)
get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt_moc_executable} PATH)
else()
get_target_property(_qt5_core_lib Qt5::Core LOCATION)
get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt5_core_lib} PATH)
get_target_property(_qt_core_lib Qt${CTK_QT_VERSION}::Core LOCATION)
get_filename_component(QT_INSTALLED_LIBRARY_DIR ${_qt_core_lib} PATH)
endif()
else()
message(FATAL_ERROR "Support for Qt${CTK_QT_VERSION} is not implemented")
Expand Down
43 changes: 35 additions & 8 deletions CMake/ctkMacroSetupQt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@
#! \ingroup CMakeUtilities
macro(ctkMacroSetupQt)

if(CTK_QT_VERSION VERSION_EQUAL "5")
if(CTK_QT_VERSION MATCHES "^(5|6)$")
cmake_minimum_required(VERSION 3.20.6)
find_package(Qt5 COMPONENTS Core)
find_package(Qt${CTK_QT_VERSION} COMPONENTS Core)

set(CTK_QT_COMPONENTS Core)

if(CTK_QT_VERSION VERSION_GREATER "5")
list(APPEND CTK_QT_COMPONENTS
Core5Compat # For QRegExp used in "ctkCommandLineParser.cpp"
StateMachine # For QAbstractTransition used in "ctkWorkflowTransitions.h"
)
endif()

# See https://github.com/commontk/CTK/wiki/Maintenance#updates-of-required-qt-components

if(CTK_LIB_Widgets
Expand All @@ -46,7 +53,9 @@ macro(ctkMacroSetupQt)
OR CTK_LIB_CommandLineModules/Core
OR CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTXMLPATTERNS
)
list(APPEND CTK_QT_COMPONENTS XmlPatterns)
if(CTK_QT_VERSION VERSION_EQUAL "5")
list(APPEND CTK_QT_COMPONENTS XmlPatterns)
endif()
endif()

if(CTK_APP_ctkCommandLineModuleExplorer
Expand Down Expand Up @@ -82,6 +91,10 @@ macro(ctkMacroSetupQt)

if(CTK_LIB_Widgets)
list(APPEND CTK_QT_COMPONENTS OpenGL)

if(CTK_QT_VERSION VERSION_GREATER "5")
list(APPEND CTK_QT_COMPONENTS OpenGLWidgets)
endif()
endif()

if(CTK_APP_ctkCommandLineModuleExplorer
Expand All @@ -108,6 +121,10 @@ macro(ctkMacroSetupQt)

if(CTK_BUILD_QTDESIGNER_PLUGINS)
list(APPEND CTK_QT_COMPONENTS Designer)

if(CTK_QT_VERSION VERSION_GREATER "5")
list(APPEND CTK_QT_COMPONENTS DesignerComponentsPrivate)
endif()
endif()

if(CTK_LIB_XNAT/Core
Expand All @@ -118,18 +135,28 @@ macro(ctkMacroSetupQt)
list(APPEND CTK_QT_COMPONENTS Network)
endif()

find_package(Qt5 COMPONENTS ${CTK_QT_COMPONENTS} REQUIRED)
if(CTK_QT_VERSION VERSION_EQUAL "5")
find_package(Qt5 COMPONENTS ${CTK_QT_COMPONENTS} REQUIRED)
mark_as_superbuild(Qt5_DIR) # Qt 5

set(_major ${Qt5_VERSION_MAJOR})
set(_minor ${Qt5_VERSION_MINOR})
set(_patch ${Qt5_VERSION_PATCH})

mark_as_superbuild(Qt5_DIR) # Qt 5
elseif(CTK_QT_VERSION VERSION_EQUAL "6")
find_package(Qt6 COMPONENTS ${CTK_QT_COMPONENTS} REQUIRED)
mark_as_superbuild(Qt6_DIR) # Qt 6

set(_major ${Qt6_VERSION_MAJOR})
set(_minor ${Qt6_VERSION_MINOR})
set(_patch ${Qt6_VERSION_PATCH})
endif()

# XXX Backward compatible way
if(DEFINED CMAKE_PREFIX_PATH)
mark_as_superbuild(CMAKE_PREFIX_PATH) # Qt 5
endif()

set(_major ${Qt5_VERSION_MAJOR})
set(_minor ${Qt5_VERSION_MINOR})
set(_patch ${Qt5_VERSION_PATCH})

ctk_list_to_string(", " "${CTK_QT_COMPONENTS}" comma_separated_module_list)
message(STATUS "Configuring CTK with Qt ${_major}.${_minor}.${_patch} (using modules: ${comma_separated_module_list})")
Expand Down
61 changes: 59 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,18 @@ mark_as_advanced(CTK_SUPERBUILD)
#-----------------------------------------------------------------------------
# Qt version
#
set(CTK_QT_VERSION "5" CACHE STRING "Expected Qt version")
if(DEFINED Qt6_DIR)
set(_default_qt_major_version "6")
else()
set(_default_qt_major_version "5")
endif()
set(CTK_QT_VERSION "${_default_qt_major_version}" CACHE STRING "Expected major Qt version")
mark_as_advanced(CTK_QT_VERSION)
set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 5)
set_property(CACHE CTK_QT_VERSION PROPERTY STRINGS 5 6)
mark_as_superbuild(CTK_QT_VERSION)
if(NOT "${CTK_QT_VERSION}" MATCHES "^(5|6)$")
message(FATAL_ERROR "CTK_QT_VERSION must be 5 or 6.")
endif()

#-----------------------------------------------------------------------------
# Output directories.
Expand Down Expand Up @@ -321,6 +329,14 @@ endif()
#
option(CTK_USE_QTTESTING "Enable/Disable QtTesting" OFF)
mark_as_advanced(CTK_USE_QTTESTING)
if(NOT CTK_QT_VERSION VERSION_EQUAL "5")
# Forcing to OFF as "QtTesting" depends on XmlPatterns Qt component not available with Qt 6
if(DEFINED CTK_USE_QTTESTING AND CTK_USE_QTTESTING)
unset(CTK_USE_QTTESTING CACHE)
set(CTK_USE_QTTESTING OFF)
message(WARNING "Forcing option [CTK_USE_QTTESTING] to OFF as QtTesting depends on XmlPatterns Qt component not available with Qt ${CTK_QT_VERSION}")
endif()
endif()
mark_as_superbuild(CTK_USE_QTTESTING)

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -503,6 +519,7 @@ ctk_lib_option(Visualization/VTK/Core
ctk_lib_option(Visualization/VTK/Widgets
"Build the VTK Widgets library" OFF)

if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_lib_option(CommandLineModules/Core
"Build the Command Line Module core library" OFF)

Expand All @@ -521,6 +538,16 @@ ctk_lib_option(CommandLineModules/Backend/LocalProcess
ctk_lib_option(CommandLineModules/Backend/FunctionPointer
"Build the Command Line Module back-end for function pointers" OFF)

else()
# "CommandLineModules/Core" depends on XmlPatterns Qt component not available with Qt 6
set(CTK_LIB_CommandLineModules/Core OFF)
set(CTK_LIB_CommandLineModules/Frontend/QtWebKit OFF)
set(CTK_LIB_CommandLineModules/Frontend/QtGui OFF)
set(CTK_LIB_CommandLineModules/Backend/XMLChecker OFF)
set(CTK_LIB_CommandLineModules/Backend/LocalProcess OFF)
set(CTK_LIB_CommandLineModules/Backend/FunctionPointer OFF)
endif()

ctk_lib_option(XNAT/Core
"Build the XNAT Core library" OFF)

Expand Down Expand Up @@ -574,6 +601,7 @@ ctk_app_option(ctkDICOMQueryRetrieve
"Build the DICOM example application" OFF
CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)

if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_app_option(ctkDICOMHost
"Build the DICOM application host example application" OFF
CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
Expand All @@ -585,6 +613,12 @@ ctk_app_option(ctkExampleHost
ctk_app_option(ctkExampleHostedApp
"Build the DICOM example application" OFF
CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
else()
# Host apps depends on "org.commontk.dah.core" which depends on QtSOAP not available with Qt 6
set(CTK_APP_ctkDICOMHost OFF)
set(CTK_APP_ctkExampleHost OFF)
set(CTK_APP_ctkExampleHostedApp OFF)
endif()

if(FALSE)
# Since EventBusDemo depends on qxmlrpc that is lacking Qt5 support, it is excluded.
Expand All @@ -593,9 +627,14 @@ ctk_app_option(ctkEventBusDemo
CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
endif()

if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_app_option(ctkCommandLineModuleExplorer
"Build the Command Line Module Explorer" OFF
CTK_BUILD_EXAMPLES)
else()
# "ctkCommandLineModuleExplorer" depends on "CommandLineModules/Core" which depends on XmlPatterns Qt component not available with Qt 6
set(CTK_APP_ctkCommandLineModuleExplorer OFF)
endif()

# We use the CTKWidgets library together with the Qt Designer plug-in
# in ctkCommandLineModuleExplorer, so enabling the options here.
Expand Down Expand Up @@ -672,6 +711,7 @@ ctk_plugin_option(org.commontk.plugingenerator.ui
CTK_APP_ctkPluginGenerator)

# Plug-ins related to DICOM WG23 (Application Hosting)
if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_plugin_option(org.commontk.dah.core "Build the org.commontk.dah.core plugin." OFF)
ctk_plugin_option(org.commontk.dah.hostedapp "Build the org.commontk.dah.hostedapp plugin." OFF
CTK_ENABLE_DICOMApplicationHosting)
Expand All @@ -681,14 +721,31 @@ ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin.
ctk_plugin_option(org.commontk.dah.exampleapp
"Build the org.commontk.dah.exampleapp plugin." OFF
CTK_APP_ctkExampleHostedApp)
Comment thread
jcfr marked this conversation as resolved.
else()
# "org.commontk.dah.core" and its dependent plugins depend on QtSOAP not available with Qt 6
set(CTK_PLUGIN_org.commontk.dah.core OFF)
set(CTK_PLUGIN_org.commontk.dah.hostedapp OFF)
set(CTK_PLUGIN_org.commontk.dah.host OFF)
set(CTK_PLUGIN_org.commontk.dah.exampleapp OFF)
endif()

if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_plugin_option(org.commontk.dah.cmdlinemoduleapp
"Build the org.commontk.dah.cmdlinemoduleapp plugin." OFF
CTK_APP_ctkCommandLineModuleApp)
else()
# "org.commontk.dah.cmdlinemoduleapp" depends on "CommandLineModules/Core" which depends on XmlPatterns Qt component not available with Qt 6
set(CTK_PLUGIN_org.commontk.dah.cmdlinemoduleapp OFF)
endif()

if(CTK_QT_VERSION VERSION_EQUAL "5")
ctk_plugin_option(org.commontk.dah.examplehost
"Build the org.commontk.dah.examplehost plugin." OFF
CTK_APP_ctkExampleHost)
else()
# "org.commontk.dah.examplehost" depends on "org.commontk.dah.core" which depends on QtSOAP not available with Qt 6
set(CTK_PLUGIN_org.commontk.dah.examplehost OFF)
endif()

# Plug-ins related to the EventBus demo application
if(FALSE)
Expand Down
Loading