From 10c4a4b4bdfdd468e52ae0fbbf84c77b64df2f8f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 3 Dec 2021 22:33:28 +0200 Subject: WIP: Change the build system to enable building with Qt 6 This was built with: -DQT_MAJOR_VERSION=6 \ -DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.90.0 \ -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055a00 Move the include(KDEInstallDirs) call before the first find_package(Qt*, the former is what auto-detects the Qt version, and defaults to 5. This is needed to be able to build against Qt5 by default. All unit tests still pass. --- autotests/CMakeLists.txt | 22 +++++++++++----------- autotests/kconfig_compiler/CMakeLists.txt | 6 +++--- autotests/kconfigtest.cpp | 26 +++++++++++++++++++------- 3 files changed, 33 insertions(+), 21 deletions(-) (limited to 'autotests') diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index cae4c0b1..a7e37e5a 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,14 +1,14 @@ include(ECMAddTests) -find_package(Qt5Test ${REQUIRED_QT_VERSION} CONFIG QUIET) -find_package(Qt5Concurrent ${REQUIRED_QT_VERSION} CONFIG QUIET) +find_package(Qt${QT_MAJOR_VERSION}Test ${REQUIRED_QT_VERSION} CONFIG QUIET) +find_package(Qt${QT_MAJOR_VERSION}Concurrent ${REQUIRED_QT_VERSION} CONFIG QUIET) -if(NOT Qt5Test_FOUND) +if(NOT Qt${QT_MAJOR_VERSION}Test_FOUND) message(STATUS "Qt5Test not found, autotests will not be built.") return() endif() -if(NOT Qt5Concurrent_FOUND) +if(NOT Qt${QT_MAJOR_VERSION}Concurrent_FOUND) message(STATUS "Qt5Concurrent not found, autotests will not be built.") return() endif() @@ -18,7 +18,7 @@ ecm_add_test( kentrymaptest.cpp ../src/core/kconfigdata.cpp TEST_NAME kentrymaptest - LINK_LIBRARIES Qt5::Test + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test ) target_include_directories(kentrymaptest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/core) @@ -27,17 +27,17 @@ ecm_add_test( test_kconfigutils.cpp ../src/kconf_update/kconfigutils.cpp TEST_NAME test_kconfigutils - LINK_LIBRARIES KF5::ConfigCore Qt5::Test + LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test ) target_include_directories(test_kconfigutils PRIVATE ../src/kconf_update) qt_add_resources(sharedconfigresources sharedconfigresources.qrc) -ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(ksharedconfigtest.cpp ${sharedconfigresources} TEST_NAME kconfigcore-ksharedconfigtest LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent) # test for fallback to :/kconfig/xxxx config resource qt_add_resources(fallbackconfigresources fallbackconfigresources.qrc) -ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent) +ecm_add_test(fallbackconfigresourcestest.cpp ${fallbackconfigresources} TEST_NAME kconfigcore-fallbackconfigresourcestest LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent) ecm_add_tests( kconfignokdehometest.cpp @@ -46,19 +46,19 @@ ecm_add_tests( test_kconf_update.cpp ksharedconfig_in_global_object.cpp NAME_PREFIX kconfigcore- - LINK_LIBRARIES KF5::ConfigCore Qt5::Test Qt5::Concurrent + LINK_LIBRARIES KF5::ConfigCore Qt${QT_MAJOR_VERSION}::Test Qt${QT_MAJOR_VERSION}::Concurrent ) target_include_directories(test_kconf_update PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src/kconf_update) -if(TARGET Qt5::Gui) +if(TARGET Qt${QT_MAJOR_VERSION}::Gui) ecm_add_tests( kconfigguitest.cpp kconfigloadertest.cpp kconfigskeletontest.cpp kstandardshortcuttest.cpp NAME_PREFIX kconfiggui- - LINK_LIBRARIES KF5::ConfigGui Qt5::Test + LINK_LIBRARIES KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test ) # These tests do a global cleanup of ~/.qttest, so they can't run in parallel diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 4caa17af..5cbf2e44 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -177,7 +177,7 @@ set(test_state_config_SRCS test_state_config_main.cpp) gen_kcfg_test_source(test_state_config test_state_config_SRCS GENERATE_MOC) ecm_add_test(TEST_NAME test_state_config ${test_state_config_SRCS}) -target_link_libraries(test_state_config KF5::ConfigGui Qt5::Test) +target_link_libraries(test_state_config KF5::ConfigGui Qt${QT_MAJOR_VERSION}::Test) ########### next target ############### @@ -234,7 +234,7 @@ gen_kcfg_test_source(signals_test_no_singleton_dpointer kconfigcompiler_test_sig ecm_add_test(${kconfigcompiler_test_signals_SRCS} TEST_NAME kconfigcompiler-signals-test - LINK_LIBRARIES Qt5::Test KF5::ConfigGui + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test KF5::ConfigGui ) ########### next target ############### @@ -261,7 +261,7 @@ ecm_add_test(${test_param_minmax_SRCS} ecm_add_test(kconfigcompiler_test.cpp TEST_NAME kconfigcompiler-basic-test - LINK_LIBRARIES Qt5::Test + LINK_LIBRARIES Qt${QT_MAJOR_VERSION}::Test ) diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 4657ea8d..95a87584 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1974,18 +1974,30 @@ void KConfigTest::testXdgListEntry() void KConfigTest::testThreads() { QThreadPool::globalInstance()->setMaxThreadCount(6); - QList> futures; // Run in parallel some tests that work on different config files, // otherwise unexpected things might indeed happen. - futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources); - futures << QtConcurrent::run(this, &KConfigTest::testSimple); - futures << QtConcurrent::run(this, &KConfigTest::testDefaults); - futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); - futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const QList> futures = { + QtConcurrent::run(&KConfigTest::testAddConfigSources, this), + QtConcurrent::run(&KConfigTest::testSimple, this), + QtConcurrent::run(&KConfigTest::testDefaults, this), + QtConcurrent::run(&KConfigTest::testSharedConfig, this), + QtConcurrent::run(&KConfigTest::testSharedConfig, this), + }; +#else + const QList> futures = { + QtConcurrent::run(this, &KConfigTest::testAddConfigSources), + QtConcurrent::run(this, &KConfigTest::testSimple), + QtConcurrent::run(this, &KConfigTest::testDefaults), + QtConcurrent::run(this, &KConfigTest::testSharedConfig), + QtConcurrent::run(this, &KConfigTest::testSharedConfig), + }; +#endif + // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); - for (QFuture f : std::as_const(futures)) { + for (QFuture f : futures) { f.waitForFinished(); } } -- cgit v1.2.1