aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <vkrause@kde.org>2022-01-23 13:06:05 +0100
committerVolker Krause <vkrause@kde.org>2022-01-23 14:04:59 +0100
commit33e3c5eb41ee9c5c3ea326e0b788f9efbfcf2e30 (patch)
tree5cc276081567bf4ff75821426bf65625d7429f2a
parent104e5fabae121155511309380bafe1c49db9089a (diff)
downloadextra-cmake-modules-33e3c5eb41ee9c5c3ea326e0b788f9efbfcf2e30.tar.gz
extra-cmake-modules-33e3c5eb41ee9c5c3ea326e0b788f9efbfcf2e30.tar.bz2
Forward the Qt6 build option to the CMake test runs
Fixes a number of unit tests that rely on Qt in some form when using Qt6.
-rw-r--r--tests/CMakeLists.txt13
-rw-r--r--tests/ECMQmlModuleTest/CMakeLists.txt5
-rw-r--r--tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt5
3 files changed, 18 insertions, 5 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f5e114c0..67d878cb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -37,12 +37,23 @@ add_subdirectory(ECMGenerateHeadersTest)
add_subdirectory(ECMSetupVersionTest)
add_subdirectory(ECMGeneratePkgConfigFile)
+if (TARGET Qt6::Core)
+ set(QT_VERSION_OPT "-DBUILD_WITH_QT6=ON")
+else()
+ set(QT_VERSION_OPT "-DBUILD_WITH_QT6=OFF")
+endif()
+
# a macro for tests that have a simple format where the name matches the
# directory and project
macro(add_test_variant NAME BASE COMMAND)
string(REPLACE "." "/" src_dir "${BASE}")
string(REPLACE "." "/" build_dir "${NAME}")
string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
+ if (NOT ${NAME}_EXTRA_OPTIONS)
+ set(_build_opts --build-options ${QT_VERSION_OPT})
+ else()
+ set(_build_opts ${${NAME}_EXTRA_OPTIONS} ${QT_VERSION_OPT})
+ endif()
add_test(${NAME} ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
@@ -51,7 +62,7 @@ macro(add_test_variant NAME BASE COMMAND)
--build-generator ${CMAKE_GENERATOR}
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
--build-project ${proj}
- ${${NAME}_EXTRA_OPTIONS}
+ ${_build_opts}
--test-command ${COMMAND} ${ARGN})
endmacro()
macro(add_test_macro NAME)
diff --git a/tests/ECMQmlModuleTest/CMakeLists.txt b/tests/ECMQmlModuleTest/CMakeLists.txt
index 49d76594..e0f9e298 100644
--- a/tests/ECMQmlModuleTest/CMakeLists.txt
+++ b/tests/ECMQmlModuleTest/CMakeLists.txt
@@ -8,8 +8,9 @@ cmake_minimum_required(VERSION 3.5)
set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../modules)
set(CMAKE_MODULE_PATH "${ECM_FIND_MODULE_DIR}" "${ECM_MODULE_DIR}")
+include(QtVersionOption)
-find_package(Qt5 REQUIRED COMPONENTS Qml)
+find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Qml)
include(ECMQmlModule)
if(QML_ONLY)
@@ -17,7 +18,7 @@ if(QML_ONLY)
else()
ecm_add_qml_module(TestModule URI Test)
target_sources(TestModule PRIVATE qmlmodule.cpp)
- target_link_libraries(TestModule Qt5::Qml)
+ target_link_libraries(TestModule Qt${QT_MAJOR_VERSION}::Qml)
endif()
if (DEPENDS)
diff --git a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
index 3e8e859e..603bd7d6 100644
--- a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
+++ b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt
@@ -4,6 +4,7 @@ set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules")
set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR})
+include(QtVersionOption)
include(ECMQtDeclareLoggingCategory)
include(CMakeParseArguments)
@@ -44,7 +45,7 @@ ecm_qt_export_logging_category(
DESCRIPTION "log 4"
)
-find_package(Qt5Core REQUIRED)
+find_package(Qt${QT_MAJOR_VERSION}Core REQUIRED)
add_executable(testmain testmain.cpp ${sources})
target_include_directories(testmain
@@ -53,7 +54,7 @@ target_include_directories(testmain
)
target_link_libraries(testmain
PRIVATE
- Qt5::Core
+ Qt${QT_MAJOR_VERSION}::Core
)
ecm_qt_install_logging_categories(