From cbf0d3da52efbff2a945f773735ae4678ec29a7a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 11:42:03 -0500 Subject: cmake-gui: Port away from deprecated API in Qt >= 6.7 --- Source/QtDialog/WarningMessagesDialog.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/QtDialog/WarningMessagesDialog.cxx b/Source/QtDialog/WarningMessagesDialog.cxx index 1fcf2b1..e409768 100644 --- a/Source/QtDialog/WarningMessagesDialog.cxx +++ b/Source/QtDialog/WarningMessagesDialog.cxx @@ -26,21 +26,23 @@ void WarningMessagesDialog::setInitialValues() void WarningMessagesDialog::setupSignals() { +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + static auto const checkStateChanged = &QCheckBox::checkStateChanged; +#else + static auto const checkStateChanged = &QCheckBox::stateChanged; +#endif QObject::connect(this->buttonBox, &QDialogButtonBox::accepted, this, &WarningMessagesDialog::doAccept); - - QObject::connect(this->suppressDeveloperWarnings, &QCheckBox::stateChanged, - this, + QObject::connect(this->suppressDeveloperWarnings, checkStateChanged, this, &WarningMessagesDialog::doSuppressDeveloperWarningsChanged); QObject::connect( - this->suppressDeprecatedWarnings, &QCheckBox::stateChanged, this, + this->suppressDeprecatedWarnings, checkStateChanged, this, &WarningMessagesDialog::doSuppressDeprecatedWarningsChanged); - QObject::connect(this->developerWarningsAsErrors, &QCheckBox::stateChanged, - this, + QObject::connect(this->developerWarningsAsErrors, checkStateChanged, this, &WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged); QObject::connect( - this->deprecatedWarningsAsErrors, &QCheckBox::stateChanged, this, + this->deprecatedWarningsAsErrors, checkStateChanged, this, &WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged); } -- cgit v0.12 From 19a1c115e0bbeda0c8dd7bcb18e82427db9b7751 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 11:46:19 -0500 Subject: cmake-gui: Fix integer conversion warnings with Qt 6 --- Source/QtDialog/QCMakeCacheView.cxx | 6 +++--- Source/QtDialog/QCMakeCacheView.h | 5 +++-- Source/QtDialog/QCMakePresetItemModel.cxx | 6 ++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 90f5ac2..8c7801b 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -187,7 +187,7 @@ QCMakeCacheModel::QCMakeCacheModel(QObject* p) QCMakeCacheModel::~QCMakeCacheModel() = default; -static uint qHash(QCMakeProperty const& p) +static size_t qHash(QCMakeProperty const& p) { return qHash(p.Key); } @@ -349,7 +349,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t) QCMakePropertyList props = this->properties(); QCMakePropertyList oldProps; - int numNew = this->NewPropertyCount; + cm_qsizetype numNew = this->NewPropertyCount; cm_qsizetype numTotal = props.count(); for (cm_qsizetype i = numNew; i < numTotal; i++) { oldProps.append(props[i]); @@ -530,7 +530,7 @@ bool QCMakeCacheModel::editEnabled() const return this->EditEnabled; } -int QCMakeCacheModel::newPropertyCount() const +cm_qsizetype QCMakeCacheModel::newPropertyCount() const { return this->NewPropertyCount; } diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 4df17f7..879caf5 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -3,6 +3,7 @@ #pragma once #include "QCMake.h" +#include "QCMakeSizeType.h" #include #include #include @@ -99,7 +100,7 @@ public: bool editEnabled() const; // returns how many new properties there are - int newPropertyCount() const; + cm_qsizetype newPropertyCount() const; // return flags (overloaded to modify flag based on EditEnabled flag) Qt::ItemFlags flags(QModelIndex const& index) const; @@ -114,7 +115,7 @@ public: protected: bool EditEnabled; - int NewPropertyCount; + cm_qsizetype NewPropertyCount; bool ShowNewProperties; ViewType View; diff --git a/Source/QtDialog/QCMakePresetItemModel.cxx b/Source/QtDialog/QCMakePresetItemModel.cxx index ac071f2..4df9b1c 100644 --- a/Source/QtDialog/QCMakePresetItemModel.cxx +++ b/Source/QtDialog/QCMakePresetItemModel.cxx @@ -83,7 +83,8 @@ int QCMakePresetItemModel::rowCount(QModelIndex const& parent) const if (this->m_presets.empty()) { return 1; } - return this->m_presets.size() + 2; + // NOLINTNEXTLINE(readability-redundant-casting) + return static_cast(this->m_presets.size() + 2); } int QCMakePresetItemModel::columnCount(QModelIndex const& parent) const @@ -144,5 +145,6 @@ int QCMakePresetItemModel::presetNameToRow(QString const& name) const index++; } - return this->m_presets.size() + 1; + // NOLINTNEXTLINE(readability-redundant-casting) + return static_cast(this->m_presets.size() + 1); } -- cgit v0.12 From e35d1ee4cd313db7e0960d3917c0d8aa879d04d3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 10:06:43 -0500 Subject: cmake-gui: Clarify variable name for selected Qt major version --- Source/QtDialog/CMakeLists.txt | 45 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 55f40bf..ce363f4 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -13,25 +13,26 @@ set(CMake_QT_MAJOR_VERSION "A" CACHE STRING "Expected Qt major version. Valid values are A (auto-select), 5, 6.") set(SUPPORTED_QT_VERSIONS "A" 5 6) set_property(CACHE CMake_QT_MAJOR_VERSION PROPERTY STRINGS ${SUPPORTED_QT_VERSIONS}) +# Select a Qt version and store it in a normal variable of the same name. if(NOT CMake_QT_MAJOR_VERSION STREQUAL "A") if(NOT CMake_QT_MAJOR_VERSION IN_LIST SUPPORTED_QT_VERSIONS) message(FATAL_ERROR "Supported Qt versions are \"${SUPPORTED_QT_VERSIONS}\"." " But CMake_QT_MAJOR_VERSION is set to ${CMake_QT_MAJOR_VERSION}.") endif() - set(INSTALLED_QT_VERSION ${CMake_QT_MAJOR_VERSION}) + set(CMake_QT_MAJOR_VERSION "${CMake_QT_MAJOR_VERSION}") else() find_package(Qt6Widgets QUIET) - set(INSTALLED_QT_VERSION 6) + set(CMake_QT_MAJOR_VERSION 6) if(NOT Qt6Widgets_FOUND) find_package(Qt5Widgets QUIET) if(NOT Qt5Widgets_FOUND) message(FATAL_ERROR "Could not find a valid Qt installation.") endif() - set(INSTALLED_QT_VERSION 5) + set(CMake_QT_MAJOR_VERSION 5) endif() endif() -find_package(Qt${INSTALLED_QT_VERSION} +find_package(Qt${CMake_QT_MAJOR_VERSION} COMPONENTS ${QT_COMPONENTS} REQUIRED QUIET ) @@ -40,10 +41,10 @@ set(CMake_QT_EXTRA_LIBRARIES) # Try to find the package WinExtras for the task bar progress if(WIN32) - find_package(Qt${INSTALLED_QT_VERSION}WinExtras QUIET) - if(Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) + find_package(Qt${CMake_QT_MAJOR_VERSION}WinExtras QUIET) + if(Qt${CMake_QT_MAJOR_VERSION}WinExtras_FOUND) add_compile_definitions(QT_WINEXTRAS) - list(APPEND CMake_QT_EXTRA_LIBRARIES Qt${INSTALLED_QT_VERSION}::WinExtras) + list(APPEND CMake_QT_EXTRA_LIBRARIES Qt${CMake_QT_MAJOR_VERSION}::WinExtras) list(APPEND QT_COMPONENTS WinExtras) endif() endif() @@ -53,7 +54,7 @@ if(MSVC) add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt${INSTALLED_QT_VERSION}Widgets_EXECUTABLE_COMPILE_FLAGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt${CMake_QT_MAJOR_VERSION}Widgets_EXECUTABLE_COMPILE_FLAGS}") if(CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES) list(APPEND CMake_QT_EXTRA_LIBRARIES ${CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES}) @@ -70,7 +71,7 @@ endif() # We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows. if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) function(_qt_get_plugin_name_with_version target out_var) - string(REGEX REPLACE "^Qt::(.+)" "Qt${INSTALLED_QT_VERSION}::\\1" + string(REGEX REPLACE "^Qt::(.+)" "Qt${CMake_QT_MAJOR_VERSION}::\\1" qt_plugin_with_version "${target}") if(TARGET "${qt_plugin_with_version}") set("${out_var}" "${qt_plugin_with_version}" PARENT_SCOPE) @@ -106,23 +107,23 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endmacro() macro(install_qt_plugins _comps _plugins_var) foreach(_qt_comp IN LISTS ${_comps}) - if(INSTALLED_QT_VERSION VERSION_LESS 6) - set(_qt_module_plugins ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_PLUGINS}) + if(CMake_QT_MAJOR_VERSION VERSION_LESS 6) + set(_qt_module_plugins ${Qt${CMake_QT_MAJOR_VERSION}${_qt_comp}_PLUGINS}) else() - get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qt_comp} QT_PLUGINS) + get_target_property(_qt_module_plugins Qt${CMake_QT_MAJOR_VERSION}::${_qt_comp} QT_PLUGINS) endif() foreach(_qt_plugin IN LISTS _qt_module_plugins) - if(INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) + if(CMake_QT_MAJOR_VERSION VERSION_GREATER_EQUAL 6) # Qt6 provides the plugins as individual packages that need to be found. - find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET - PATHS ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_DIR}) + find_package(Qt${CMake_QT_MAJOR_VERSION}${_qt_plugin} QUIET + PATHS ${Qt${CMake_QT_MAJOR_VERSION}${_qt_comp}_DIR}) endif() install_qt_plugin("${_qt_plugin}" "${_plugins_var}") endforeach() endforeach() endmacro() if(APPLE) - if(INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(CMake_QT_MAJOR_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) if(TARGET Qt5::QMacStylePlugin) install_qt_plugin("Qt5::QMacStylePlugin" QT_PLUGINS) @@ -137,7 +138,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" ${COMPONENT}) elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES) - if(INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(CMake_QT_MAJOR_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS) else() # FIXME: Minimize plugins for Qt6. @@ -151,7 +152,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endif() endif() -get_property(_Qt_Core_LOCATION TARGET Qt${INSTALLED_QT_VERSION}::Core PROPERTY LOCATION) +get_property(_Qt_Core_LOCATION TARGET Qt${CMake_QT_MAJOR_VERSION}::Core PROPERTY LOCATION) get_filename_component(Qt_BIN_DIR "${_Qt_Core_LOCATION}" PATH) if(APPLE) get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH) @@ -194,8 +195,8 @@ target_link_libraries( PUBLIC CMakeLib ${CMake_QT_EXTRA_LIBRARIES} - Qt${INSTALLED_QT_VERSION}::Core - Qt${INSTALLED_QT_VERSION}::Widgets + Qt${CMake_QT_MAJOR_VERSION}::Core + Qt${CMake_QT_MAJOR_VERSION}::Widgets ) set(UI_SRCS @@ -223,7 +224,7 @@ set(MOC_SRCS ) set(QRC_SRCS CMakeSetup.qrc) -if(INSTALLED_QT_VERSION VERSION_LESS 6) +if(CMake_QT_MAJOR_VERSION VERSION_LESS 6) qt5_wrap_ui(UI_BUILT_SRCS ${UI_SRCS}) qt5_wrap_cpp(MOC_BUILT_SRCS ${MOC_SRCS}) qt5_add_resources(QRC_BUILT_SRCS ${QRC_SRCS}) @@ -269,7 +270,7 @@ target_link_libraries(cmake-gui CMakeGUIQRCLib $ ManifestLib - Qt${INSTALLED_QT_VERSION}::Core + Qt${CMake_QT_MAJOR_VERSION}::Core ) if(WIN32) -- cgit v0.12 From 5afbc739dc91ffeaca2ff2dfe47c873f583f5cb5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 21 Feb 2025 11:31:26 -0500 Subject: ci: Specify Qt version separately for each Fedora build Currently all builds use Qt 5. Prepare to switch some to Qt 6. --- .gitlab/ci/configure_fedora41_asan.cmake | 1 + .gitlab/ci/configure_fedora41_clang_analyzer.cmake | 1 + .gitlab/ci/configure_fedora41_common.cmake | 1 - .gitlab/ci/configure_fedora41_makefiles_symlinked.cmake | 1 + .gitlab/ci/configure_fedora41_ninja.cmake | 2 ++ .gitlab/ci/configure_fedora41_tidy.cmake | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/configure_fedora41_asan.cmake b/.gitlab/ci/configure_fedora41_asan.cmake index df9f46d..4441792 100644 --- a/.gitlab/ci/configure_fedora41_asan.cmake +++ b/.gitlab/ci/configure_fedora41_asan.cmake @@ -1,4 +1,5 @@ set(CMAKE_C_FLAGS "-fsanitize=address" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fsanitize=address" CACHE STRING "") +set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") diff --git a/.gitlab/ci/configure_fedora41_clang_analyzer.cmake b/.gitlab/ci/configure_fedora41_clang_analyzer.cmake index cdeaab4..4a518d0 100644 --- a/.gitlab/ci/configure_fedora41_clang_analyzer.cmake +++ b/.gitlab/ci/configure_fedora41_clang_analyzer.cmake @@ -1,3 +1,4 @@ set(configure_no_sccache 1) +set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") diff --git a/.gitlab/ci/configure_fedora41_common.cmake b/.gitlab/ci/configure_fedora41_common.cmake index 4484e26..dee78ab 100644 --- a/.gitlab/ci/configure_fedora41_common.cmake +++ b/.gitlab/ci/configure_fedora41_common.cmake @@ -1,6 +1,5 @@ set(BUILD_CursesDialog ON CACHE BOOL "") set(BUILD_QtDialog ON CACHE BOOL "") -set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") set(CMake_TEST_JQ "/usr/bin/jq" CACHE PATH "") set(CMake_TEST_JSON_SCHEMA ON CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake b/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake index e4434c1..6dd27f8 100644 --- a/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake +++ b/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake @@ -1,2 +1,3 @@ +set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_symlinked_common.cmake") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") diff --git a/.gitlab/ci/configure_fedora41_ninja.cmake b/.gitlab/ci/configure_fedora41_ninja.cmake index 217d24a..9bef7e8 100644 --- a/.gitlab/ci/configure_fedora41_ninja.cmake +++ b/.gitlab/ci/configure_fedora41_ninja.cmake @@ -14,5 +14,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING "") # Cover compilation with C++11 only and not higher standards. set(CMAKE_CXX_STANDARD "11" CACHE STRING "") +# Qt 6 requires C++17, so use Qt 5. +set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") diff --git a/.gitlab/ci/configure_fedora41_tidy.cmake b/.gitlab/ci/configure_fedora41_tidy.cmake index 40bde10..664b4f1 100644 --- a/.gitlab/ci/configure_fedora41_tidy.cmake +++ b/.gitlab/ci/configure_fedora41_tidy.cmake @@ -2,5 +2,6 @@ set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "") set(CMake_USE_CLANG_TIDY_MODULE ON CACHE BOOL "") set(CMake_CLANG_TIDY_MODULE "$ENV{CI_PROJECT_DIR}/Utilities/ClangTidyModule/build/libcmake-clang-tidy-module.so" CACHE FILEPATH "") set(CMake_CLANG_TIDY_EXPORT_FIXES_DIR "$ENV{CI_PROJECT_DIR}/.gitlab/clang-tidy-fixes" CACHE PATH "") +set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") -- cgit v0.12 From 245f5ca8b3dc15d534e729f99c26764870dc5fa7 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 20 Feb 2025 11:09:08 +0100 Subject: Tests: Make CMakeGUI test build with both Qt5 and Qt6 Fixes: #26710 --- .../configure_fedora41_makefiles_symlinked.cmake | 4 +- Source/QtDialog/CMakeLists.txt | 1 + Tests/CMakeGUI/CMakeGUITest.cxx | 3 +- Tests/CMakeGUI/CMakeLists.txt | 56 +++++++++++++++++----- Tests/CMakeGUI/QCMakePresetItemModelTest.cxx | 2 + 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake b/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake index 6dd27f8..317de3a 100644 --- a/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake +++ b/.gitlab/ci/configure_fedora41_makefiles_symlinked.cmake @@ -1,3 +1,5 @@ -set(CMake_QT_MAJOR_VERSION "5" CACHE STRING "") +set(CMake_QT_MAJOR_VERSION "6" CACHE STRING "") +set(CMake_TEST_GUI "ON" CACHE BOOL "") + include("${CMAKE_CURRENT_LIST_DIR}/configure_symlinked_common.cmake") include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora41_common.cmake") diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index ce363f4..7f851bd 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -264,6 +264,7 @@ target_link_libraries( ) add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx) +set_property(TARGET cmake-gui PROPERTY CMake_QT_MAJOR_VERSION "${CMake_QT_MAJOR_VERSION}") target_link_libraries(cmake-gui PRIVATE CMakeGUIMainLib diff --git a/Tests/CMakeGUI/CMakeGUITest.cxx b/Tests/CMakeGUI/CMakeGUITest.cxx index a3414fd..c6b6f63 100644 --- a/Tests/CMakeGUI/CMakeGUITest.cxx +++ b/Tests/CMakeGUI/CMakeGUITest.cxx @@ -75,7 +75,8 @@ void CMakeGUITest::tryConfigure(int expectedResult, int timeout) Qt::QueuedConnection); QVERIFY(configureDoneSpy.wait(timeout)); - QCOMPARE(configureDoneSpy, { { expectedResult } }); + QList configureDoneSignalArguments = configureDoneSpy.takeFirst(); + QCOMPARE(configureDoneSignalArguments.at(0).toInt(), expectedResult); } void CMakeGUITest::sourceBinaryArgs() diff --git a/Tests/CMakeGUI/CMakeLists.txt b/Tests/CMakeGUI/CMakeLists.txt index c9f44e9..d4c9bf8 100644 --- a/Tests/CMakeGUI/CMakeLists.txt +++ b/Tests/CMakeGUI/CMakeLists.txt @@ -1,6 +1,8 @@ include(CMakeParseArguments) -find_package(Qt5Test REQUIRED) +get_property(CMake_QT_MAJOR_VERSION TARGET cmake-gui PROPERTY CMake_QT_MAJOR_VERSION) + +find_package(Qt${CMake_QT_MAJOR_VERSION}Test REQUIRED) if(MSVC) # QTBUG-118993: Qt uses deprecated stdext::checked_array_iterator @@ -14,21 +16,40 @@ include_directories( ) set(MOC_SRCS) -qt5_wrap_cpp(MOC_SRCS - CatchShow.h - ) +if(CMake_QT_MAJOR_VERSION VERSION_LESS 6) + qt5_wrap_cpp(MOC_SRCS + CatchShow.h + ) +else() + qt_wrap_cpp(MOC_SRCS + CatchShow.h + ) +endif() add_library(CMakeGUITestLib STATIC ${MOC_SRCS} CatchShow.cxx CatchShow.h ) -target_link_libraries(CMakeGUITestLib Qt5::Core Qt5::Gui Qt5::Widgets) +target_link_libraries(CMakeGUITestLib + Qt${CMake_QT_MAJOR_VERSION}::Core + Qt${CMake_QT_MAJOR_VERSION}::Gui + Qt${CMake_QT_MAJOR_VERSION}::Widgets) set(MOC_SRCS) -qt5_wrap_cpp(MOC_SRCS - CMakeGUITest.h - ) +if(CMake_QT_MAJOR_VERSION VERSION_LESS 6) + qt5_wrap_cpp(MOC_SRCS + CMakeGUITest.h + ) +else() + qt_wrap_cpp(MOC_SRCS + CMakeGUITest.h + ) +endif() add_executable(CMakeGUITest CMakeGUITest.cxx ${MOC_SRCS}) -target_link_libraries(CMakeGUITest CMakeGUIMainLib CMakeGUITestLib Qt5::Core Qt5::Test Qt5::Widgets) +target_link_libraries(CMakeGUITest CMakeGUIMainLib CMakeGUITestLib + Qt${CMake_QT_MAJOR_VERSION}::Core + Qt${CMake_QT_MAJOR_VERSION}::Test + Qt${CMake_QT_MAJOR_VERSION}::Widgets +) target_compile_definitions(CMakeGUITest PRIVATE "CMakeGUITest_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" "CMakeGUITest_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" @@ -47,11 +68,20 @@ function(add_cmake_gui_lib_test name) cmake_parse_arguments(_t "" "" "SOURCES;MOC_SOURCES" ${ARGN}) set(MOC_SRCS) - qt5_wrap_cpp(MOC_SRCS - ${_t_MOC_SOURCES} - ) + if(CMake_QT_MAJOR_VERSION VERSION_LESS 6) + qt5_wrap_cpp(MOC_SRCS + ${_t_MOC_SOURCES} + ) + else() + qt_wrap_cpp(MOC_SRCS + ${_t_MOC_SOURCES} + ) + endif() add_executable(${name} ${_t_SOURCES} ${MOC_SRCS}) - target_link_libraries(${name} CMakeGUILib CMakeGUITestLib Qt5::Core Qt5::Test Qt5::Widgets) + target_link_libraries(${name} CMakeGUILib CMakeGUITestLib + Qt${CMake_QT_MAJOR_VERSION}::Core + Qt${CMake_QT_MAJOR_VERSION}::Test + Qt${CMake_QT_MAJOR_VERSION}::Widgets) add_test(NAME "CMakeGUILib.${name}" COMMAND ${name}) endfunction() diff --git a/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx b/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx index 97dbb30..a2320b3 100644 --- a/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx +++ b/Tests/CMakeGUI/QCMakePresetItemModelTest.cxx @@ -17,7 +17,9 @@ using QItemDataHash = QHash; void QCMakePresetItemModelTest::initTestCase() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QMetaType::registerComparators(); +#endif } void QCMakePresetItemModelTest::initTestCase_data() -- cgit v0.12