summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r--tests/auto/cmake/CMakeLists.txt254
-rw-r--r--tests/auto/cmake/mockplugins/.cmake.conf1
-rw-r--r--tests/auto/cmake/mockplugins/CMakeLists.txt33
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt13
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt13
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt13
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt13
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h51
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/configure.cmake2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/fake.cpp29
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h55
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt12
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins2/fake.cpp29
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/configure.cmake2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/fake.cpp29
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h55
-rw-r--r--tests/auto/cmake/test(needsquoting)dirname/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp29
-rw-r--r--tests/auto/cmake/test(needsquoting)dirname/mywidget.h29
-rw-r--r--tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp29
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt9
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.cpp29
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.h29
-rw-r--r--tests/auto/cmake/test_QTP0003/CMakeLists.txt66
-rw-r--r--tests/auto/cmake/test_QTP0003/source.cpp4
-rw-r--r--tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/CMakeLists.txt23
-rw-r--r--tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/data/testdata.txt1
-rw-r--r--tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp32
-rw-r--r--tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/testdata.txt1
-rw-r--r--tests/auto/cmake/test_add_big_resource/CMakeLists.txt10
-rw-r--r--tests/auto/cmake/test_add_big_resource/myobject.cpp29
-rw-r--r--tests/auto/cmake/test_add_big_resource/myobject.h29
-rw-r--r--tests/auto/cmake/test_add_big_resource/subdir/subdir_resource_file.txt1
-rw-r--r--tests/auto/cmake/test_add_big_resource/subdir/test_add_big_resource.qrc5
-rw-r--r--tests/auto/cmake/test_add_binary_resources_delayed_file/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp30
-rw-r--r--tests/auto/cmake/test_add_resource_options/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_add_resource_options/myobject.cpp29
-rw-r--r--tests/auto/cmake/test_add_resource_options/myobject.h29
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt25
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/main.cpp26
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/resource_file.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt45
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp20
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h9
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp13
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h8
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/main.cpp35
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource1.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource2.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/resource3.txt1
-rw-r--r--tests/auto/cmake/test_add_resources_binary_generated/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_add_resources_binary_generated/main.cpp33
-rw-r--r--tests/auto/cmake/test_add_resources_delayed_file/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_add_resources_delayed_file/main.cpp29
-rw-r--r--tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt33
-rw-r--r--tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp4
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt25
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/main.cpp13
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro5
-rw-r--r--tests/auto/cmake/test_collecting_plugins/CMakeLists.txt31
-rw-r--r--tests/auto/cmake/test_collecting_plugins/main.cpp7
-rw-r--r--tests/auto/cmake/test_collecting_plugins/plugin.cpp18
-rw-r--r--tests/auto/cmake/test_concurrent_module/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_concurrent_module/main.cpp29
-rw-r--r--tests/auto/cmake/test_config_expressions/CMakeLists.txt134
-rw-r--r--tests/auto/cmake/test_dbus_module/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_dbus_module/mydbusobject.cpp29
-rw-r--r--tests/auto/cmake/test_dbus_module/mydbusobject.h29
-rw-r--r--tests/auto/cmake/test_dependent_modules/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_dependent_modules/mywidget.cpp29
-rw-r--r--tests/auto/cmake/test_dependent_modules/mywidget.h29
-rw-r--r--tests/auto/cmake/test_egl_lib/main.cpp29
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/.cmake.conf1
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt24
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt22
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp9
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h20
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp11
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt24
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp9
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h20
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp11
-rw-r--r--tests/auto/cmake/test_global_promotion/CMakeLists.txt16
-rw-r--r--tests/auto/cmake/test_global_promotion/subdir_with_global_qt/CMakeLists.txt17
-rw-r--r--tests/auto/cmake/test_global_promotion/subdir_with_local_qt/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/test_import_plugins/CMakeLists.txt233
-rw-r--r--tests/auto/cmake/test_import_plugins/check.cpp.in2
-rw-r--r--tests/auto/cmake/test_import_plugins/main.cpp55
-rw-r--r--tests/auto/cmake/test_interface/CMakeLists.txt25
-rw-r--r--tests/auto/cmake/test_interface/main.cpp29
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.cpp29
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.h29
-rw-r--r--tests/auto/cmake/test_interface/widget_test/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/test_interface/widget_test/main.cpp4
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/main.cpp29
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/somelib.cpp29
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/somelib.h29
-rw-r--r--tests/auto/cmake/test_json_plugin_includes/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_json_plugin_includes/plugin.cpp29
-rw-r--r--tests/auto/cmake/test_json_plugin_includes/plugin.h29
-rw-r--r--tests/auto/cmake/test_moc_macro_target/CMakeLists.txt34
-rw-r--r--tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake15
-rw-r--r--tests/auto/cmake/test_moc_macro_target/interface/myinterface.h29
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp29
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp29
-rw-r--r--tests/auto/cmake/test_moc_macro_target/mywrapobject.h29
-rw-r--r--tests/auto/cmake/test_multiple_find_package/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_multiple_find_package/main.cpp29
-rw-r--r--tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_opengl_lib/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_opengl_lib/main.cpp29
-rw-r--r--tests/auto/cmake/test_platform_defs_include/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_platform_defs_include/main.cpp29
-rw-r--r--tests/auto/cmake/test_plugin_shared_static_flavor.cmake27
-rw-r--r--tests/auto/cmake/test_plugin_shared_static_flavor/CMakeLists.txt34
-rw-r--r--tests/auto/cmake/test_plugins/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_private_includes/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_private_includes/main.cpp29
-rw-r--r--tests/auto/cmake/test_private_targets/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_private_targets/main.cpp29
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt123
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt45
-rw-r--r--tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts1
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/CMakeLists.txt109
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/CMakeLists.txt24
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/MetaType.cpp4
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/main.cpp7
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/.gitattributes1
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmpty.h10
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmptyWithComment.h11
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECT.h10
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECTandQ_PROPERTY.h13
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesEmpty.json2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECT.json19
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECTandQ_PROPERTY.json34
-rw-r--r--tests/auto/cmake/test_qt_manual_moc/CMakeLists.txt61
-rw-r--r--tests/auto/cmake/test_qt_manual_moc/VerifyDefines.cmake30
-rw-r--r--tests/auto/cmake/test_qt_manual_moc/testclass.cpp8
-rw-r--r--tests/auto/cmake/test_qt_manual_moc/testclass.h17
-rw-r--r--tests/auto/cmake/test_qt_manual_moc/testclass1.h17
-rw-r--r--tests/auto/cmake/test_qtmainwin_library/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_qtmainwin_library/myobject.cpp29
-rw-r--r--tests/auto/cmake/test_qtmainwin_library/myobject.h29
-rw-r--r--tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt33
-rw-r--r--tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp4
-rw-r--r--tests/auto/cmake/test_resource_without_obj_lib/main.cpp28
-rw-r--r--tests/auto/cmake/test_resource_without_obj_lib/resource.txt1
-rw-r--r--tests/auto/cmake/test_standalone_test/CMakeLists.txt14
-rw-r--r--tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp22
-rw-r--r--tests/auto/cmake/test_static_resources/.cmake.conf1
-rw-r--r--tests/auto/cmake/test_static_resources/CMakeLists.txt26
-rw-r--r--tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt21
-rw-r--r--tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake2
-rw-r--r--tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp4
-rw-r--r--tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt0
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt36
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp24
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp33
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt0
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt0
-rw-r--r--tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt180
-rw-r--r--tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp23
-rw-r--r--tests/auto/cmake/test_testlib_definitions/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_testlib_definitions/main.cpp29
-rw-r--r--tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_umbrella_config/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/test_versionless_targets/CMakeLists.txt108
-rw-r--r--tests/auto/cmake/test_versionless_targets/default/CMakeLists.txt17
-rw-r--r--tests/auto/cmake/test_versionless_targets/force_off/CMakeLists.txt18
-rw-r--r--tests/auto/cmake/test_versionless_targets/force_old/CMakeLists.txt21
-rw-r--r--tests/auto/cmake/test_versionless_targets/force_on/CMakeLists.txt20
-rw-r--r--tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt74
-rw-r--r--tests/auto/cmake/test_widgets_app_deployment/main.cpp22
-rw-r--r--tests/auto/cmake/test_wrap_cpp_and_resources/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp29
-rw-r--r--tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h29
-rw-r--r--tests/auto/cmake/test_wrap_cpp_moc/CMakeLists.txt19
-rw-r--r--tests/auto/cmake/test_wrap_cpp_moc/main.cpp17
-rw-r--r--tests/auto/cmake/test_wrap_cpp_options/CMakeLists.txt5
-rw-r--r--tests/auto/cmake/test_wrap_cpp_options/myobject.cpp29
-rw-r--r--tests/auto/cmake/test_wrap_cpp_options/myobject.h29
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt52
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/plugin.cpp45
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/plugin.json3
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp44
204 files changed, 3147 insertions, 1842 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 996fb979cf..3331ad260d 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -1,4 +1,5 @@
-# special case skip regeneration
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
# This is an automatic test for the CMake configuration files.
# To run it manually,
@@ -40,9 +41,26 @@
# needs to be set to the installation prefix or build prefix of Qt
# before running these tests.
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(cmake_usage_tests)
+include(GNUInstallDirs)
+
+# Building the CMake tests as part of a Qt prefix build + in-tree tests, currently doesn't work.
+# Each CMake test will fail with a message like
+#
+# CMake Error at qtbase/lib/cmake/Qt6/Qt6Config.cmake:33 (include):
+# include could not find load file:
+# qtbase/lib/cmake/Qt6/Qt6Targets.cmake
+#
+# That's because the Qt packages are not installed, and we try to load the Config files from the
+# build dir, but they can't work in a prefix build without installation.
+# Configuring the tests as standalone tests or as a separate project works fine.
+# Configuring the tests in-tree also works fine in a non-prefix build.
+if(QT_REPO_MODULE_VERSION AND NOT QT_BUILD_STANDALONE_TESTS AND QT_WILL_INSTALL)
+ message(WARNING
+ "Skipping building CMake build tests because they don't work in a prefix in-tree config")
+endif()
enable_testing()
@@ -51,7 +69,8 @@ enable_testing()
# flag. Notably -rpath is specified which should implicitly enable -rpath-link, but that
# doesn't seem to be the case.
# Until this is figured out, disable the tests when cross-compiling to Linux.
-if(UNIX AND NOT APPLE AND NOT WIN32 AND CMAKE_CROSSCOMPILING AND NOT QT_ENABLE_CMAKE_BOOT2QT_TESTS)
+if(UNIX AND NOT APPLE AND NOT WIN32 AND CMAKE_CROSSCOMPILING AND NOT QT_ENABLE_CMAKE_BOOT2QT_TESTS
+ AND NOT QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS)
message(STATUS "Running CMake tests is disabled when cross-compiling to Linux / Boot2Qt.")
return()
endif()
@@ -69,13 +88,10 @@ find_package(Qt6 REQUIRED COMPONENTS ${required_packages})
find_package(Qt6 OPTIONAL_COMPONENTS ${optional_packages})
# Setup common test variables which were previously set by ctest_testcase_common.prf.
-set(CMAKE_MODULES_UNDER_TEST "${required_packages}")
-foreach(qt_package ${optional_packages})
- set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}")
- list(APPEND CMAKE_MODULES_UNDER_TEST "${qt_package}")
-endforeach()
+set(CMAKE_MODULES_UNDER_TEST "${required_packages}" ${optional_packages})
foreach(qt_package ${CMAKE_MODULES_UNDER_TEST})
+ set(package_name "${QT_CMAKE_EXPORT_NAMESPACE}${qt_package}")
if(${package_name}_FOUND)
set(CMAKE_${qt_package}_MODULE_MAJOR_VERSION "${${package_name}_VERSION_MAJOR}")
set(CMAKE_${qt_package}_MODULE_MINOR_VERSION "${${package_name}_VERSION_MINOR}")
@@ -96,38 +112,108 @@ endif()
include("${_Qt6CTestMacros}")
+# Test only multi-abi specific functionality when QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS is ON.
+# Qt::Gui is the prerequisite for all Android tests.
+if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS AND NOT NO_GUI)
+ unset(multi_abi_vars)
+ foreach(abi IN LISTS QT_ANDROID_ABIS)
+ list(APPEND multi_abi_vars "-DQT_PATH_ANDROID_ABI_${abi}=${QT_PATH_ANDROID_ABI_${abi}}")
+ endforeach()
+ if(QT_ANDROID_BUILD_ALL_ABIS)
+ list(APPEND multi_abi_vars "-DQT_ANDROID_BUILD_ALL_ABIS=${QT_ANDROID_BUILD_ALL_ABIS}")
+ endif()
+
+ list(APPEND multi_abi_vars "-DQT_HOST_PATH=${QT_HOST_PATH}")
+
+ set(multi_abi_forward_vars
+ TEST_SINGLE_VALUE_ARG
+ TEST_SPACES_VALUE_ARG
+ TEST_LIST_VALUE_ARG
+ TEST_ESCAPING_VALUE_ARG
+ )
+ string(REPLACE ";" "[[;]]" multi_abi_forward_vars "${multi_abi_forward_vars}")
+
+ set(single_value "TestValue")
+ set(list_value "TestValue[[;]]TestValue2[[;]]TestValue3")
+ set(escaping_value "TestValue\\\\[[;]]TestValue2\\\\[[;]]TestValue3")
+ set(spaces_value "TestValue TestValue2 TestValue3")
+ _qt_internal_test_expect_pass(test_android_multi_abi_forward_vars
+ BUILD_OPTIONS
+ ${multi_abi_vars}
+ "-DQT_ANDROID_MULTI_ABI_FORWARD_VARS=${multi_abi_forward_vars}"
+ "-DTEST_SINGLE_VALUE_ARG=${single_value}"
+ "-DTEST_LIST_VALUE_ARG=${list_value}"
+ "-DTEST_ESCAPING_VALUE_ARG=${escaping_value}"
+ "-DTEST_SPACES_VALUE_ARG=${spaces_value}"
+ )
+ return()
+endif()
+
+if(NOT NO_WIDGETS)
+ _qt_internal_test_expect_pass(test_build_simple_widget_app)
+ set(extra_widget_app_options "")
+ if(IOS)
+ list(APPEND extra_widget_app_options
+ QMAKE_OPTIONS CONFIG+=iossimulator
+ )
+ endif()
+ if(CMAKE_HOST_WIN32)
+ # Unset MAKEFLAGS environment variable when invoking build tool, it might
+ # have options incompatible with nmake.
+ list(APPEND extra_widget_app_options
+ BUILD_ENVIRONMENT MAKEFLAGS ""
+ )
+ endif()
+
+ _qt_internal_add_qmake_test(test_build_simple_widget_app
+ TESTNAME test_build_simple_widget_app_qmake
+ ${extra_widget_app_options}
+ )
+endif()
+
+# We only support a limited subset of cmake tests when targeting iOS:
+# - Only those that use qt_add_executable (but not add_executable)
+# - and don't try to run the built binaries via BINARY_ARGS option
+# - and don't use internal API like qt_internal_add_*
+#
+# So we can't run binaries in the simulator or on-device, but we at least
+# want build coverage (app linking succeeds).
+if(IOS)
+ return()
+endif()
+
+set(is_qt_build_platform TRUE)
+# macOS versions less than 10.15 are not supported for building Qt.
+if(CMAKE_HOST_APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS "19.0.0")
+ set(is_qt_build_platform FALSE)
+endif()
+
_qt_internal_test_expect_pass(test_umbrella_config)
_qt_internal_test_expect_pass(test_wrap_cpp_and_resources)
if (NOT NO_WIDGETS)
_qt_internal_test_expect_pass(test_dependent_modules)
_qt_internal_test_expect_pass("test(needsquoting)dirname")
endif()
-_qt_internal_test_expect_fail(test_add_resource_options)
-_qt_internal_test_expect_fail(test_wrap_cpp_options)
+_qt_internal_test_expect_pass(test_add_resource_prefix BINARY test_add_resource_prefix)
+_qt_internal_test_expect_build_fail(test_add_resource_options)
+_qt_internal_test_expect_build_fail(test_wrap_cpp_options)
+_qt_internal_test_expect_pass(test_wrap_cpp_moc)
_qt_internal_test_expect_pass(test_platform_defs_include)
_qt_internal_test_expect_pass(test_qtmainwin_library)
if (CMAKE_GENERATOR STREQUAL Ninja AND UNIX AND NOT WIN32)
- set(qfindtestdata_build_dir "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build")
- add_test(test_QFINDTESTDATA ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA"
- # Build in a subdir of the source dir.
- # This causes Ninja to use relative paths.
- "${qfindtestdata_build_dir}"
- --build-config "${CMAKE_BUILD_TYPE}"
- --build-generator "${CMAKE_GENERATOR}"
- --build-makeprogram "${CMAKE_MAKE_PROGRAM}"
- --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST}
+ _qt_internal_test_expect_pass(test_QFINDTESTDATA
+ BINARY "tests/test_QFINDTESTDATA"
+ SIMULATE_IN_SOURCE
)
- set_tests_properties(test_QFINDTESTDATA PROPERTIES FIXTURES_SETUP QFINDTESTDATA)
-
- add_test(NAME run_test_QFINDTESTDATA COMMAND sh -c "cd \"${qfindtestdata_build_dir}/tests\" && ./test_QFINDTESTDATA -v2")
- set_tests_properties(run_test_QFINDTESTDATA PROPERTIES FIXTURES_REQUIRED QFINDTESTDATA)
-
- # source dir should be untouched by build, so remove build results
- add_test(NAME cleanup_test_QFINDTESTDATA COMMAND sh -c "rm -rf \"${qfindtestdata_build_dir}\"")
- set_tests_properties(cleanup_test_QFINDTESTDATA PROPERTIES FIXTURES_CLEANUP QFINDTESTDATA)
+ # TODO: Decide if there's a reason to keep this test. With CMake 3.21.0 which passes absolute
+ # source file paths to the compiler (instead of relative ones), specifying a custom
+ # QT_TESTCASE_BUILDDIR is a no-op, which fails the test's preconditions.
+ # See QTBUG-95268.
+ #_qt_internal_test_expect_pass(test_QT_TESTCASE_BUILDDIR
+ # BINARY "test_qt_testcase_builddir"
+ # SIMULATE_IN_SOURCE
+ #)
endif()
if (NOT NO_DBUS)
@@ -136,6 +222,8 @@ endif()
_qt_internal_test_expect_pass(test_multiple_find_package)
_qt_internal_test_expect_pass(test_add_resources_delayed_file)
_qt_internal_test_expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file)
+_qt_internal_test_expect_pass(test_qt_add_resources_rebuild)
+_qt_internal_test_expect_pass(test_resource_without_obj_lib BINARY test_resource_without_obj_lib)
if(NOT NO_GUI)
_qt_internal_test_expect_pass(test_private_includes)
@@ -146,16 +234,15 @@ _qt_internal_test_expect_pass(test_testlib_definitions)
_qt_internal_test_expect_pass(test_json_plugin_includes)
if(NOT NO_GUI)
- _qt_internal_test_expect_fail(test_testlib_no_link_gui)
+ _qt_internal_test_expect_build_fail(test_testlib_no_link_gui)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+ "${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp"
+ "${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_gui/test_testlib_no_link_gui/"
+ )
endif()
-execute_process(COMMAND ${CMAKE_COMMAND} -E copy
- "${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp"
- "${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_gui/test_testlib_no_link_gui/"
-)
-
if (NOT NO_WIDGETS)
- _qt_internal_test_expect_fail(test_testlib_no_link_widgets)
+ _qt_internal_test_expect_build_fail(test_testlib_no_link_widgets)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/test_testlib_definitions/main.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/failbuild/test_testlib_no_link_widgets/test_testlib_no_link_widgets/"
@@ -220,9 +307,100 @@ if(NOT NO_WIDGETS)
_qt_internal_test_expect_pass(test_QTBUG-63422)
endif()
-# FIXME: Needs porting of the qmake .pro files to create the modules and plugins in Qt6 CMake land.
-# _qt_internal_test_expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND})
+# Find main Qt installation location and bin dir.
+if(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX)
+ set(qt_install_prefix "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}")
+elseif(QT6_INSTALL_PREFIX)
+ set(qt_install_prefix "${QT6_INSTALL_PREFIX}")
+endif()
+
+if(INSTALL_LIBEXECDIR)
+ set(qt_install_libexec_dir "${INSTALL_LIBEXECDIR}")
+elseif(QT6_INSTALL_LIBEXECS)
+ set(qt_install_libexec_dir "${QT6_INSTALL_LIBEXECS}")
+endif()
+
+# Test building and installing a few dummy Qt modules and plugins.
+if(is_qt_build_platform)
+ set(mockplugins_test_args "")
+ if(NOT QT_FEATURE_no_prefix)
+ list(APPEND mockplugins_test_args
+ BINARY "${CMAKE_COMMAND}"
+ BINARY_ARGS
+ "-DQT_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/mockplugins"
+ -P "${qt_install_prefix}/${qt_install_libexec_dir}/qt-cmake-private-install.cmake"
+ )
+ endif()
+ _qt_internal_test_expect_pass(mockplugins ${mockplugins_test_args})
+ set_tests_properties(mockplugins PROPERTIES FIXTURES_SETUP build_mockplugins)
+
+ # Test importing the plugins built in the project above.
+ _qt_internal_test_expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND} BINARY_ARGS -V)
+ set_tests_properties(test_import_plugins PROPERTIES FIXTURES_REQUIRED build_mockplugins)
+endif()
+
+if(NOT NO_GUI)
+ _qt_internal_test_expect_pass(test_standalone_test
+ BINARY "${CMAKE_CTEST_COMMAND}"
+ BINARY_ARGS "-V")
+endif()
+
_qt_internal_test_expect_pass(test_versionless_targets)
+if(NOT NO_GUI)
+ _qt_internal_test_expect_pass(test_global_promotion)
+endif()
+
_qt_internal_test_expect_pass(test_add_resources_binary_generated
BINARY test_add_resources_binary_generated)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17")
+ _qt_internal_test_expect_pass(test_add_resources_big_resources
+ BINARY test_add_resources_big_resources)
+endif()
+
+include(test_plugin_shared_static_flavor.cmake)
+_qt_internal_test_expect_pass(tst_qaddpreroutine
+ BINARY tst_qaddpreroutine)
+
+if(is_qt_build_platform)
+ _qt_internal_test_expect_pass(test_static_resources
+ BINARY "${CMAKE_CTEST_COMMAND}"
+ BINARY_ARGS "-V")
+
+ _qt_internal_test_expect_pass(test_generating_cpp_exports)
+endif()
+
+_qt_internal_test_expect_pass(test_qt_extract_metatypes)
+
+set(deploy_args
+ test_widgets_app_deployment
+ BINARY "${CMAKE_CTEST_COMMAND}"
+ BINARY_ARGS "-V"
+ # Need to explicitly specify a writable install prefix.
+ BUILD_OPTIONS
+ -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_widgets_app_deployment_installed
+ NO_RUN_ENVIRONMENT_PLUGIN_PATH
+)
+
+set(is_desktop_linux FALSE)
+if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING)
+ set(is_desktop_linux TRUE)
+endif()
+
+# For now, the test should only pass on Windows, macOS and desktop Linux shared and static builds
+# and fail on other platforms, because there is no support for runtime dependency deployment on
+# those platforms.
+# With static builds the runtime dependencies are just skipped, but the test should still pass.
+if(WIN32 OR (APPLE AND NOT IOS) OR is_desktop_linux)
+ _qt_internal_test_expect_pass(${deploy_args})
+else()
+ _qt_internal_test_expect_fail(${deploy_args})
+endif()
+
+_qt_internal_test_expect_pass(test_config_expressions)
+_qt_internal_test_expect_pass(test_QTP0003)
+if(NOT NO_GUI)
+ _qt_internal_test_expect_pass(test_collecting_plugins)
+endif()
+
+_qt_internal_test_expect_pass(test_qt_manual_moc)
diff --git a/tests/auto/cmake/mockplugins/.cmake.conf b/tests/auto/cmake/mockplugins/.cmake.conf
new file mode 100644
index 0000000000..10bc1fd407
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/.cmake.conf
@@ -0,0 +1 @@
+set(QT_REPO_MODULE_VERSION "6.8.0")
diff --git a/tests/auto/cmake/mockplugins/CMakeLists.txt b/tests/auto/cmake/mockplugins/CMakeLists.txt
new file mode 100644
index 0000000000..1bde9aedb1
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+include(.cmake.conf)
+project(QtMockPlugins
+ VERSION "${QT_REPO_MODULE_VERSION}"
+ DESCRIPTION "Qt MockPlugins Libraries"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+)
+
+find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core)
+qt_internal_project_setup()
+
+find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Widgets Xml)
+
+qt_build_repo_begin()
+
+add_subdirectory(mockplugins1)
+add_subdirectory(mockplugins2)
+add_subdirectory(mockplugins3)
+
+add_subdirectory(mock1plugin)
+add_subdirectory(mock2plugin)
+add_subdirectory(mock3plugin)
+add_subdirectory(mock4plugin)
+add_subdirectory(mock5plugin)
+add_subdirectory(mock6plugin)
+
+qt_build_repo_post_process()
+qt_build_repo_end()
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt
new file mode 100644
index 0000000000..5a37ef9ea0
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock1Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock1Plugin
+ PLUGIN_TYPE mockplugin
+ SOURCES
+ qmock1plugin.cpp qmock1plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins1
+)
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
index e2e114b1d9..324d0c38f4 100644
--- a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
+++ b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK1PLUGIN_H
#define QMOCK1PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt
new file mode 100644
index 0000000000..f2705335f5
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock2Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock2Plugin
+ PLUGIN_TYPE mockplugin
+ SOURCES
+ qmock2plugin.cpp qmock2plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins1
+)
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
index be99133dc8..a1217ff4d6 100644
--- a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
+++ b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK2PLUGIN_H
#define QMOCK2PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt
new file mode 100644
index 0000000000..b165353b24
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock3Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock3Plugin
+ PLUGIN_TYPE mockplugin
+ SOURCES
+ qmock3plugin.cpp qmock3plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins1
+)
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
index 08d1aa68ce..3e152784e0 100644
--- a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
+++ b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK3PLUGIN_H
#define QMOCK3PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt
new file mode 100644
index 0000000000..cf09fb294b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock4Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock4Plugin
+ PLUGIN_TYPE mockplugin
+ DEFAULT_IF FALSE
+ SOURCES
+ qmock4plugin.cpp qmock4plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins1
+)
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
index 0776bef002..1895367575 100644
--- a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
+++ b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK4PLUGIN_H
#define QMOCK4PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt
new file mode 100644
index 0000000000..1d34cabe1f
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock5Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock5Plugin
+ PLUGIN_TYPE mockplugin
+ DEFAULT_IF FALSE
+ SOURCES
+ qmock5plugin.cpp qmock5plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins3
+)
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
index 2f387da203..4b6c95fb23 100644
--- a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
+++ b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK5PLUGIN_H
#define QMOCK5PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt
new file mode 100644
index 0000000000..5d80407d57
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(QMock6Plugin
+ NO_UNITY_BUILD
+ CLASS_NAME QMock6Plugin
+ PLUGIN_TYPE mockauxplugin
+ SOURCES
+ qmock6plugin.cpp qmock6plugin.h
+ LIBRARIES
+ Qt::Core
+ Qt::MockPlugins3
+)
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
index 6b29b6703b..5278d67960 100644
--- a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
+++ b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCK6PLUGIN_H
#define QMOCK6PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt
new file mode 100644
index 0000000000..adba60e42d
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(MockPlugins1
+ NO_UNITY_BUILD
+ PLUGIN_TYPES mockplugin
+ SOURCES
+ qmockplugin.h
+ fake.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/configure.cmake b/tests/auto/cmake/mockplugins/mockplugins1/configure.cmake
new file mode 100644
index 0000000000..46da2db2b8
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins1/configure.cmake
@@ -0,0 +1,2 @@
+# This is needed so that MODULE_PLUGIN_TYPES property is set on the exported target.
+# Fun times.
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
index f95eba6055..6cdf6a09ce 100644
--- a/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtGlobal>
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
index 9427ae9212..d4dcea5c20 100644
--- a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
+++ b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCKPLUGIN_H
#define QMOCKPLUGIN_H
-#include <QString>
-#include <QtPlugin>
+#include <QtCore/QString>
+#include <QtCore/QtPlugin>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt
new file mode 100644
index 0000000000..a797206cd6
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(MockPlugins2
+ NO_UNITY_BUILD
+ SOURCES
+ fake.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
diff --git a/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
index 384623d646..9256ef181f 100644
--- a/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtGlobal>
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt
new file mode 100644
index 0000000000..b8e3c54535
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(MockPlugins3
+ NO_UNITY_BUILD
+ PLUGIN_TYPES mockauxplugin
+ SOURCES
+ qmockauxplugin.h
+ fake.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/configure.cmake b/tests/auto/cmake/mockplugins/mockplugins3/configure.cmake
new file mode 100644
index 0000000000..46da2db2b8
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins3/configure.cmake
@@ -0,0 +1,2 @@
+# This is needed so that MODULE_PLUGIN_TYPES property is set on the exported target.
+# Fun times.
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
index 9ec2b42181..9ca82b9ef7 100644
--- a/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtGlobal>
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
index 25e4762bac..599c3ecbb4 100644
--- a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
+++ b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
@@ -1,58 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCKAUXPLUGIN_H
#define QMOCKAUXPLUGIN_H
-#include <QString>
-#include <QtPlugin>
+#include <QtCore/QString>
+#include <QtCore/QtPlugin>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/cmake/test(needsquoting)dirname/CMakeLists.txt b/tests/auto/cmake/test(needsquoting)dirname/CMakeLists.txt
index d9aaf18f14..1916c048d3 100644
--- a/tests/auto/cmake/test(needsquoting)dirname/CMakeLists.txt
+++ b/tests/auto/cmake/test(needsquoting)dirname/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project("test(needsquoting)dirname")
diff --git a/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp b/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
index 67cda1c329..da7f51d286 100644
--- a/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
+++ b/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mywidget.h"
#include "ui_mywidget.h"
diff --git a/tests/auto/cmake/test(needsquoting)dirname/mywidget.h b/tests/auto/cmake/test(needsquoting)dirname/mywidget.h
index dfa65a8503..4517670b56 100644
--- a/tests/auto/cmake/test(needsquoting)dirname/mywidget.h
+++ b/tests/auto/cmake/test(needsquoting)dirname/mywidget.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYWIDGET_H
#define MYWIDGET_H
diff --git a/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt b/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt
index c14ebb6375..12ac9c9d6a 100644
--- a/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt
+++ b/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_QFINDTESTDATA)
diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt b/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt
index 6515aa8020..6d49ab8c3b 100644
--- a/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt
+++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt
@@ -1,6 +1,7 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
add_executable(test_QFINDTESTDATA WIN32 main.cpp)
target_link_libraries(test_QFINDTESTDATA Qt::Test)
-target_compile_definitions(test_QFINDTESTDATA PRIVATE QT_TESTCASE_BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}")
-target_compile_definitions(test_QFINDTESTDATA PRIVATE QT_TESTCASE_SOURCEDIR="${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
index 56996814c2..7938bbb863 100644
--- a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
+++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Stephen Kelly <steveire@gmail,com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Stephen Kelly <steveire@gmail,com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QCoreApplication>
#include <QtTest/QTest>
diff --git a/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt
index f2ac2a1ea2..535af3d4b5 100644
--- a/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt
+++ b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt
@@ -1,4 +1,11 @@
-cmake_minimum_required(VERSION 3.14)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+if(POLICY CMP0099)
+ cmake_policy(SET CMP0099 NEW) # Avoid CMP0099 related warnings.
+endif()
+
project(test_dependent_modules)
find_package(Qt6Widgets REQUIRED)
diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
index 7bc42537d5..adbfcd35e8 100644
--- a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mywidget.h"
#include "ui_mywidget.h"
diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.h b/tests/auto/cmake/test_QTBUG-63422/mywidget.h
index d0c79c0538..f975ae2fa3 100644
--- a/tests/auto/cmake/test_QTBUG-63422/mywidget.h
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk <kevin.funk@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYWIDGET_H
#define MYWIDGET_H
diff --git a/tests/auto/cmake/test_QTP0003/CMakeLists.txt b/tests/auto/cmake/test_QTP0003/CMakeLists.txt
new file mode 100644
index 0000000000..8dda76fdb0
--- /dev/null
+++ b/tests/auto/cmake/test_QTP0003/CMakeLists.txt
@@ -0,0 +1,66 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_QTP0003)
+
+find_package(Qt6 COMPONENTS Core REQUIRED)
+
+if(QT6_IS_SHARED_LIBS_BUILD)
+ set(qt_build_type "SHARED_LIBRARY")
+else()
+ set(qt_build_type "STATIC_LIBRARY")
+endif()
+
+set(BUILD_SHARED_LIBS ON)
+qt6_add_library(MyLib source.cpp)
+get_target_property(type MyLib TYPE)
+if(NOT "${type}" STREQUAL "${qt_build_type}")
+ message(FATAL_ERROR "The library uses the default type different from Qt build type when"
+ "QTP0003 is not set")
+endif()
+
+set(BUILD_SHARED_LIBS OFF)
+qt6_add_library(MyLib2 source.cpp)
+get_target_property(type MyLib2 TYPE)
+if(NOT "${type}" STREQUAL "${qt_build_type}")
+ message(FATAL_ERROR "The library uses the default type different from Qt build type when"
+ "QTP0003 is not set")
+endif()
+
+set(BUILD_SHARED_LIBS ON)
+qt_policy(SET QTP0003 OLD)
+qt6_add_library(MyLib3 source.cpp)
+get_target_property(type MyLib3 TYPE)
+if(NOT "${type}" STREQUAL "${qt_build_type}")
+ message(FATAL_ERROR "The library uses the default type different from Qt build type when"
+ "QTP0003 is set to OLD")
+endif()
+
+set(BUILD_SHARED_LIBS OFF)
+qt_policy(SET QTP0003 OLD)
+qt6_add_library(MyLib4 source.cpp)
+get_target_property(type MyLib4 TYPE)
+if(NOT "${type}" STREQUAL "${qt_build_type}")
+ message(FATAL_ERROR "The library uses the default type different from Qt build type when"
+ "QTP0003 is set to OLD")
+endif()
+
+set(BUILD_SHARED_LIBS ON)
+qt_policy(SET QTP0003 NEW)
+qt6_add_library(MyLib5 source.cpp)
+get_target_property(type MyLib5 TYPE)
+if(NOT "${type}" STREQUAL "SHARED_LIBRARY")
+ message(FATAL_ERROR "The library doesn't consider the BUILD_SHARED_LIBS when"
+ "QTP0003 is set to NEW")
+endif()
+
+set(BUILD_SHARED_LIBS OFF)
+qt_policy(SET QTP0003 NEW)
+qt6_add_library(MyLib6 source.cpp)
+get_target_property(type MyLib6 TYPE)
+if(NOT "${type}" STREQUAL "STATIC_LIBRARY")
+ message(FATAL_ERROR "The library doesn't consider the BUILD_SHARED_LIBS when"
+ "QTP0003 is set to NEW")
+endif()
diff --git a/tests/auto/cmake/test_QTP0003/source.cpp b/tests/auto/cmake/test_QTP0003/source.cpp
new file mode 100644
index 0000000000..273d7dade4
--- /dev/null
+++ b/tests/auto/cmake/test_QTP0003/source.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+class Noop {};
diff --git a/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/CMakeLists.txt b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/CMakeLists.txt
new file mode 100644
index 0000000000..6e2a7d57bf
--- /dev/null
+++ b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# The test is simply testing that manual specification of QT_TESTCASE_BUILDDIR works,
+# despite the weird paths.
+cmake_minimum_required(VERSION 3.16)
+
+project(test_qt_testcase_builddir)
+
+find_package(Qt6Test REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+add_executable(test_qt_testcase_builddir WIN32 main.cpp)
+
+target_link_libraries(test_qt_testcase_builddir Qt::Test)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/testdata.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/level1/level2/testdata_build.txt"
+ COPYONLY
+)
+set_target_properties(test_qt_testcase_builddir PROPERTIES
+ QT_TESTCASE_BUILDDIR "${CMAKE_CURRENT_BINARY_DIR}/level1/level2"
+)
diff --git a/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/data/testdata.txt b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/data/testdata.txt
new file mode 100644
index 0000000000..e846386066
--- /dev/null
+++ b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/data/testdata.txt
@@ -0,0 +1 @@
+This is the test data found in QT_TESTCASE_SOURCEDIR.
diff --git a/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp
new file mode 100644
index 0000000000..ae34d13ff1
--- /dev/null
+++ b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QCoreApplication>
+#include <QtTest/QTest>
+#include <QDebug>
+
+class TestClass : public QObject
+{
+ Q_OBJECT
+public:
+ TestClass(QObject *parent = nullptr) { }
+
+private slots:
+ void doTest();
+};
+
+void TestClass::doTest()
+{
+ QFile fsrc(QFINDTESTDATA("data/testdata.txt"));
+ QVERIFY(fsrc.open(QFile::ReadOnly));
+ QCOMPARE(fsrc.readAll().trimmed(),
+ QByteArrayLiteral("This is the test data found in QT_TESTCASE_SOURCEDIR."));
+
+ QFile fbuild(QFINDTESTDATA("level2/testdata_build.txt"));
+ QVERIFY(fbuild.open(QFile::ReadOnly));
+ QCOMPARE(fbuild.readAll().trimmed(),
+ QByteArrayLiteral("This is the test data found in custom QT_TESTCASE_BUILDDIR."));
+}
+
+QTEST_MAIN(TestClass)
+#include "main.moc"
diff --git a/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/testdata.txt b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/testdata.txt
new file mode 100644
index 0000000000..96a369071b
--- /dev/null
+++ b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/testdata.txt
@@ -0,0 +1 @@
+This is the test data found in custom QT_TESTCASE_BUILDDIR.
diff --git a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
index f9014aac06..bee8472475 100644
--- a/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_big_resource/CMakeLists.txt
@@ -1,13 +1,19 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+cmake_minimum_required(VERSION 3.16)
project(test_add_big_resource)
+# Make sure that AUTOMOC does not interfere with qt_add_big_resources
+set(CMAKE_AUTOMOC ON)
+
find_package(Qt6Core REQUIRED)
qt_wrap_cpp(moc_files myobject.h)
-qt_add_big_resources(rcc_files "test_add_big_resource.qrc" "test_add_big_resource2.qrc")
+qt_add_big_resources(rcc_files "test_add_big_resource.qrc" "test_add_big_resource2.qrc"
+ "subdir/test_add_big_resource.qrc")
add_executable(myobject myobject.cpp ${moc_files} ${rcc_files})
target_link_libraries(myobject PRIVATE Qt::Core)
diff --git a/tests/auto/cmake/test_add_big_resource/myobject.cpp b/tests/auto/cmake/test_add_big_resource/myobject.cpp
index 5d320b8592..34c2ccc6bf 100644
--- a/tests/auto/cmake/test_add_big_resource/myobject.cpp
+++ b/tests/auto/cmake/test_add_big_resource/myobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "myobject.h"
diff --git a/tests/auto/cmake/test_add_big_resource/myobject.h b/tests/auto/cmake/test_add_big_resource/myobject.h
index c5b32c680d..87d7bfa3df 100644
--- a/tests/auto/cmake/test_add_big_resource/myobject.h
+++ b/tests/auto/cmake/test_add_big_resource/myobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/tests/auto/cmake/test_add_big_resource/subdir/subdir_resource_file.txt b/tests/auto/cmake/test_add_big_resource/subdir/subdir_resource_file.txt
new file mode 100644
index 0000000000..2c604a4f18
--- /dev/null
+++ b/tests/auto/cmake/test_add_big_resource/subdir/subdir_resource_file.txt
@@ -0,0 +1 @@
+Ken sent me.
diff --git a/tests/auto/cmake/test_add_big_resource/subdir/test_add_big_resource.qrc b/tests/auto/cmake/test_add_big_resource/subdir/test_add_big_resource.qrc
new file mode 100644
index 0000000000..9bf4f19823
--- /dev/null
+++ b/tests/auto/cmake/test_add_big_resource/subdir/test_add_big_resource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>subdir_resource_file.txt</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/cmake/test_add_binary_resources_delayed_file/CMakeLists.txt b/tests/auto/cmake/test_add_binary_resources_delayed_file/CMakeLists.txt
index 6077139e08..9a247bc684 100644
--- a/tests/auto/cmake/test_add_binary_resources_delayed_file/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_binary_resources_delayed_file/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_add_binary_resources_delayed_file)
diff --git a/tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp b/tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp
index ce4a9a60da..f0bc74403c 100644
--- a/tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp
+++ b/tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 André Klitzing <aklitzing@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 André Klitzing <aklitzing@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QResource>
@@ -34,6 +9,7 @@ int main(int argc, char **argv)
if (QResource::registerResource("rcc_file.rcc") &&
QFile::exists("://resource_file.txt") && QFile::exists("://resource_file_two.txt"))
{
+ QResource::unregisterResource("rcc_file.rcc"); // avoid leaks
return 0;
}
diff --git a/tests/auto/cmake/test_add_resource_options/CMakeLists.txt b/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
index 148dbec462..d7bb053714 100644
--- a/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_resource_options/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_add_resource_options)
diff --git a/tests/auto/cmake/test_add_resource_options/myobject.cpp b/tests/auto/cmake/test_add_resource_options/myobject.cpp
index 600281e1db..14e00e789a 100644
--- a/tests/auto/cmake/test_add_resource_options/myobject.cpp
+++ b/tests/auto/cmake/test_add_resource_options/myobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "myobject.h"
diff --git a/tests/auto/cmake/test_add_resource_options/myobject.h b/tests/auto/cmake/test_add_resource_options/myobject.h
index c5b32c680d..87d7bfa3df 100644
--- a/tests/auto/cmake/test_add_resource_options/myobject.h
+++ b/tests/auto/cmake/test_add_resource_options/myobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt
new file mode 100644
index 0000000000..65faa4cb09
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_add_resource_prefix)
+
+find_package(Qt6 REQUIRED
+ COMPONENTS Core Test
+)
+
+set(CMAKE_AUTOMOC ON)
+
+add_executable(test_add_resource_prefix main.cpp)
+
+# Tests if "/" is being used when PREFIX is missing
+qt_add_resources(test_add_resource_prefix "resources_without_prefix"
+ FILES resource_file.txt)
+
+# Tests if the PREFIX parameter is being respected
+qt_add_resources(test_add_resource_prefix "resources_with_prefix"
+ PREFIX "/resources"
+ FILES resource_file.txt)
+
+target_link_libraries(test_add_resource_prefix PRIVATE Qt::Core Qt::Test)
diff --git a/tests/auto/cmake/test_add_resource_prefix/main.cpp b/tests/auto/cmake/test_add_resource_prefix/main.cpp
new file mode 100644
index 0000000000..1a8b37715b
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/main.cpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QFile>
+#include <QtTest>
+
+class TestAddResourcePrefix : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceInDefaultPathExists();
+ void resourceInGivenPathExists();
+};
+
+void TestAddResourcePrefix::resourceInDefaultPathExists()
+{
+ QVERIFY(QFile::exists(":/resource_file.txt"));
+}
+
+void TestAddResourcePrefix::resourceInGivenPathExists()
+{
+ QVERIFY(QFile::exists(":/resources/resource_file.txt"));
+}
+
+QTEST_MAIN(TestAddResourcePrefix)
+#include "main.moc"
diff --git a/tests/auto/cmake/test_add_resource_prefix/resource_file.txt b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt
new file mode 100644
index 0000000000..2c604a4f18
--- /dev/null
+++ b/tests/auto/cmake/test_add_resource_prefix/resource_file.txt
@@ -0,0 +1 @@
+Ken sent me.
diff --git a/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt b/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt
new file mode 100644
index 0000000000..9f9ae6a43c
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/CMakeLists.txt
@@ -0,0 +1,45 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_add_resources_big_resources)
+
+if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+endif()
+
+find_package(Qt6 REQUIRED
+ COMPONENTS Core Test
+ HINTS ${Qt6Tests_PREFIX_PATH}
+)
+
+qt6_add_library(leaf_lib STATIC leaf_lib.cpp)
+qt6_add_resources(leaf_lib resources2
+ FILES resource2.txt PREFIX "/" BIG_RESOURCES)
+target_link_libraries(leaf_lib PRIVATE Qt6::Core)
+
+if(NOT TARGET leaf_lib_resources2_obj)
+ message(FATAL_ERROR "Object library for resources2 was not created.")
+endif()
+
+qt6_add_library(intermediate_lib STATIC intermediate_lib.cpp)
+qt6_add_resources(intermediate_lib resources3
+ FILES resource3.txt PREFIX "/" BIG_RESOURCES
+)
+target_link_libraries(intermediate_lib PRIVATE Qt6::Core leaf_lib)
+
+if(NOT TARGET intermediate_lib_resources3_obj)
+ message(FATAL_ERROR "Object library for resources3 was not created.")
+endif()
+
+set(CMAKE_AUTOMOC ON)
+
+qt6_add_executable(test_add_resources_big_resources main.cpp)
+qt6_add_resources(test_add_resources_big_resources resources1
+ FILES resource1.txt PREFIX "/" BIG_RESOURCES)
+target_link_libraries(test_add_resources_big_resources PRIVATE Qt6::Test intermediate_lib)
+
+if(NOT TARGET test_add_resources_big_resources_resources1_obj)
+ message(FATAL_ERROR "Object library for resources1 was not created.")
+endif()
diff --git a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
new file mode 100644
index 0000000000..a8f2be6955
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
@@ -0,0 +1,20 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "leaf_lib.h"
+
+#include <QtCore/qfile.h>
+
+namespace intermediate_lib {
+
+bool isLeafLibResourceAvailable()
+{
+ return leaf_lib::isResourceAvailable();
+}
+
+bool isResourceAvailable()
+{
+ return QFile::exists(u":/resource3.txt"_qs);
+}
+
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
new file mode 100644
index 0000000000..efa03e8a5e
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
@@ -0,0 +1,9 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+namespace intermediate_lib {
+bool isLeafLibResourceAvailable();
+bool isResourceAvailable();
+} //namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
new file mode 100644
index 0000000000..8363ceec0a
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/qfile.h>
+
+namespace leaf_lib {
+
+bool isResourceAvailable()
+{
+ return QFile::exists(u":/resource2.txt"_qs);
+}
+
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
new file mode 100644
index 0000000000..71195a7c74
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
@@ -0,0 +1,8 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+namespace leaf_lib {
+bool isResourceAvailable();
+} // namespace
diff --git a/tests/auto/cmake/test_add_resources_big_resources/main.cpp b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
new file mode 100644
index 0000000000..8ff0c4f54c
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "intermediate_lib.h"
+
+#include <QtCore/qfile.h>
+#include <QtTest/QtTest>
+
+class TestAddResourcesBigResources : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceInApplicationExists();
+ void resourceInIntermediateLibExists();
+ void resourceInLeafLibExists();
+};
+
+void TestAddResourcesBigResources::resourceInApplicationExists()
+{
+ QVERIFY(QFile::exists(":/resource1.txt"));
+}
+
+void TestAddResourcesBigResources::resourceInIntermediateLibExists()
+{
+ QVERIFY(intermediate_lib::isResourceAvailable());
+}
+
+void TestAddResourcesBigResources::resourceInLeafLibExists()
+{
+ QVERIFY(intermediate_lib::isLeafLibResourceAvailable());
+}
+
+QTEST_MAIN(TestAddResourcesBigResources)
+#include "main.moc"
+
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource1.txt b/tests/auto/cmake/test_add_resources_big_resources/resource1.txt
new file mode 100644
index 0000000000..bc06a6d721
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource1.txt
@@ -0,0 +1 @@
+Test resource1
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource2.txt b/tests/auto/cmake/test_add_resources_big_resources/resource2.txt
new file mode 100644
index 0000000000..b8f9e67458
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource2.txt
@@ -0,0 +1 @@
+Test resource2
diff --git a/tests/auto/cmake/test_add_resources_big_resources/resource3.txt b/tests/auto/cmake/test_add_resources_big_resources/resource3.txt
new file mode 100644
index 0000000000..0ed6318a85
--- /dev/null
+++ b/tests/auto/cmake/test_add_resources_big_resources/resource3.txt
@@ -0,0 +1 @@
+Test resource3
diff --git a/tests/auto/cmake/test_add_resources_binary_generated/CMakeLists.txt b/tests/auto/cmake/test_add_resources_binary_generated/CMakeLists.txt
index a764e68cc7..df9ef0c3bb 100644
--- a/tests/auto/cmake/test_add_resources_binary_generated/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_resources_binary_generated/CMakeLists.txt
@@ -1,4 +1,7 @@
-cmake_minimum_required(VERSION 3.14)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
project(test_add_resources_binary_generated)
diff --git a/tests/auto/cmake/test_add_resources_binary_generated/main.cpp b/tests/auto/cmake/test_add_resources_binary_generated/main.cpp
index bee714bcf9..73177555d4 100644
--- a/tests/auto/cmake/test_add_resources_binary_generated/main.cpp
+++ b/tests/auto/cmake/test_add_resources_binary_generated/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QResource>
@@ -37,5 +12,9 @@ int main(int, char **)
|| !QFile::exists(":/resource2.txt")) {
return -1;
}
+
+ // Avoid leaks
+ QResource::unregisterResource(RESOURCE1_FULL_PATH);
+ QResource::unregisterResource(RESOURCE2_FULL_PATH);
return 0;
}
diff --git a/tests/auto/cmake/test_add_resources_delayed_file/CMakeLists.txt b/tests/auto/cmake/test_add_resources_delayed_file/CMakeLists.txt
index e62f16d4c1..1a320dadf0 100644
--- a/tests/auto/cmake/test_add_resources_delayed_file/CMakeLists.txt
+++ b/tests/auto/cmake/test_add_resources_delayed_file/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_add_resources_delayed_file)
diff --git a/tests/auto/cmake/test_add_resources_delayed_file/main.cpp b/tests/auto/cmake/test_add_resources_delayed_file/main.cpp
index 59371ed6cb..1a1596dd6a 100644
--- a/tests/auto/cmake/test_add_resources_delayed_file/main.cpp
+++ b/tests/auto/cmake/test_add_resources_delayed_file/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qglobal.h>
diff --git a/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt b/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt
new file mode 100644
index 0000000000..0f84d5ff3e
--- /dev/null
+++ b/tests/auto/cmake/test_android_multi_abi_forward_vars/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_android_multi_abi_forward_vars)
+
+find_package(Qt6 COMPONENTS Core Gui REQUIRED)
+
+if(NOT TEST_SINGLE_VALUE_ARG STREQUAL "TestValue")
+ message(FATAL_ERROR
+ "TEST_SINGLE_VALUE_ARG is not valid: ${TEST_SINGLE_VALUE_ARG}")
+endif()
+
+if(NOT TEST_LIST_VALUE_ARG STREQUAL "TestValue;TestValue2;TestValue3")
+ message(FATAL_ERROR
+ "TEST_LIST_VALUE_ARG is not valid: ${TEST_LIST_VALUE_ARG}")
+endif()
+
+if(NOT TEST_ESCAPING_VALUE_ARG STREQUAL "TestValue\;TestValue2\;TestValue3")
+ message(FATAL_ERROR
+ "TEST_ESCAPING_VALUE_ARG is not valid: ${TEST_ESCAPING_VALUE_ARG}")
+endif()
+
+if(NOT TEST_SPACES_VALUE_ARG STREQUAL "TestValue TestValue2 TestValue3")
+ message(FATAL_ERROR
+ "TEST_SPACES_VALUE_ARG is not valid: ${TEST_SPACES_VALUE_ARG}")
+endif()
+
+# Make sure that ABI external projects are created
+qt6_add_executable(test_executable main.cpp)
+
+target_link_libraries(test_executable PRIVATE Qt::Core Qt::Gui)
diff --git a/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp
new file mode 100644
index 0000000000..304c7b20dc
--- /dev/null
+++ b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main(int, char *[]) { return 0; }
diff --git a/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt b/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
new file mode 100644
index 0000000000..1fcd026cce
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/CMakeLists.txt
@@ -0,0 +1,25 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(ios_projects LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+function(create_target target)
+ qt_add_executable(${target}
+ main.cpp
+ )
+ set_target_properties(${target} PROPERTIES
+ MACOSX_BUNDLE TRUE
+ )
+ target_link_libraries(${target} PUBLIC
+ Qt::Widgets
+ )
+endfunction()
+
+create_target(simple_widget_app)
+
diff --git a/tests/auto/cmake/test_build_simple_widget_app/main.cpp b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
new file mode 100644
index 0000000000..b4502fa05a
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
@@ -0,0 +1,13 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QApplication>
+#include <QWidget>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QWidget widget;
+ widget.show();
+ return app.exec();
+}
diff --git a/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro b/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro
new file mode 100644
index 0000000000..30834e2ee2
--- /dev/null
+++ b/tests/auto/cmake/test_build_simple_widget_app/test_build_simple_widget_app.pro
@@ -0,0 +1,5 @@
+TEMPLATE = app
+SOURCES += main.cpp
+QT += widgets
+CONFIG += app_bundle
+TARGET = simple_widget_app
diff --git a/tests/auto/cmake/test_collecting_plugins/CMakeLists.txt b/tests/auto/cmake/test_collecting_plugins/CMakeLists.txt
new file mode 100644
index 0000000000..246acd4c71
--- /dev/null
+++ b/tests/auto/cmake/test_collecting_plugins/CMakeLists.txt
@@ -0,0 +1,31 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_collecting_plugins
+ VERSION
+ "${CMAKE_Core_MODULE_MAJOR_VERSION}.${CMAKE_Core_MODULE_MINOR_VERSION}.${CMAKE_Core_MODULE_PATCH_VERSION}")
+
+find_package(Qt6 COMPONENTS Core Gui BuildInternals REQUIRED)
+
+qt_prepare_standalone_project()
+
+qt_internal_add_plugin(QTestImagePlugin
+ SHARED
+ PLUGIN_TYPE imageformats
+ SOURCES
+ plugin.cpp
+ LIBRARIES
+ Qt6::Gui
+ SKIP_INSTALL # Make sure that we do not package this plugin
+)
+
+qt_add_executable(TestExecutable main.cpp)
+target_link_libraries(TestExecutable PRIVATE Qt6::Gui)
+
+__qt_internal_collect_plugin_targets_from_dependencies(TestExecutable plugin_targets)
+
+if(NOT "QTestImagePlugin" IN_LIST plugin_targets)
+ message(FATAL_ERROR "QTestImagePlugin plugin is missing")
+endif()
diff --git a/tests/auto/cmake/test_collecting_plugins/main.cpp b/tests/auto/cmake/test_collecting_plugins/main.cpp
new file mode 100644
index 0000000000..09225de205
--- /dev/null
+++ b/tests/auto/cmake/test_collecting_plugins/main.cpp
@@ -0,0 +1,7 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main(int, char *[])
+{
+ return 0;
+}
diff --git a/tests/auto/cmake/test_collecting_plugins/plugin.cpp b/tests/auto/cmake/test_collecting_plugins/plugin.cpp
new file mode 100644
index 0000000000..f844d86c4e
--- /dev/null
+++ b/tests/auto/cmake/test_collecting_plugins/plugin.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qimageiohandler.h>
+
+class TestImagePlugin : public QImageIOPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface")
+public:
+ Capabilities capabilities(QIODevice *, const QByteArray &) const override { return {}; }
+ QImageIOHandler *create(QIODevice *, const QByteArray & = QByteArray()) const override
+ {
+ return nullptr;
+ }
+};
+
+#include "plugin.moc"
diff --git a/tests/auto/cmake/test_concurrent_module/CMakeLists.txt b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt
index 621499808e..f2d108274c 100644
--- a/tests/auto/cmake/test_concurrent_module/CMakeLists.txt
+++ b/tests/auto/cmake/test_concurrent_module/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_concurrent_module)
diff --git a/tests/auto/cmake/test_concurrent_module/main.cpp b/tests/auto/cmake/test_concurrent_module/main.cpp
index 1164b555f0..9412c60638 100644
--- a/tests/auto/cmake/test_concurrent_module/main.cpp
+++ b/tests/auto/cmake/test_concurrent_module/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtConcurrent>
#include <QtConcurrent/QtConcurrent>
diff --git a/tests/auto/cmake/test_config_expressions/CMakeLists.txt b/tests/auto/cmake/test_config_expressions/CMakeLists.txt
new file mode 100644
index 0000000000..e3863b738a
--- /dev/null
+++ b/tests/auto/cmake/test_config_expressions/CMakeLists.txt
@@ -0,0 +1,134 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_config_expressions)
+
+find_package(Qt6 REQUIRED)
+include(QtFeature)
+
+function(assert expected_value)
+ set(expression ${ARGN})
+ qt_evaluate_config_expression(result ${expression})
+ if(NOT "${result}" STREQUAL "${expected_value}")
+ message(FATAL_ERROR
+ "Unexpected value '${result}' when evaluating expression '${expression}'.")
+ endif()
+endfunction()
+
+function(assert_T)
+ assert(ON ${ARGN})
+endfunction()
+
+function(assert_F)
+ assert(OFF ${ARGN})
+endfunction()
+
+function(expect_failure expected_value)
+ set(expression ${ARGN})
+ qt_evaluate_config_expression(result ${expression})
+ if("${result}" STREQUAL "${expected_value}")
+ message(FATAL_ERROR
+ "Expression '${expression}' unexpectedly evaluated to the correct value '${result}'.")
+ endif()
+endfunction()
+
+function(expect_failure_T)
+ expect_failure(ON ${ARGN})
+endfunction()
+
+function(expect_failure_F)
+ expect_failure(OFF ${ARGN})
+endfunction()
+
+assert_T(ON)
+assert_T(TRUE)
+assert_F(OFF)
+assert_F(FALSE)
+
+assert_T(NOT FALSE)
+assert_F(NOT TRUE)
+
+assert_T(TRUE OR TRUE)
+assert_T(TRUE OR FALSE)
+assert_T(FALSE OR TRUE)
+assert_F(FALSE OR FALSE)
+
+assert_T(TRUE AND TRUE)
+assert_F(TRUE AND FALSE)
+assert_F(FALSE AND TRUE)
+assert_F(FALSE AND FALSE)
+
+# string comparison
+set(str1 "foo")
+set(str2 "bar")
+assert_T(str1 STREQUAL "foo")
+assert_T(str1 STREQUAL 'foo')
+expect_failure_T(str1 STREQUAL str1) # variable on rhs not supported
+expect_failure_T("foo" STREQUAL "foo") # literal on lhs not supported
+expect_failure_T('foo' STREQUAL 'foo') # literal on lhs not supported
+
+# comparison with empty string
+set(empty_string "")
+assert_T(empty_string STREQUAL '')
+assert_F(empty_string STREQUAL "x")
+
+# string matching
+set(processor ppc64)
+assert_T(${processor} MATCHES "(ppc|ppc64)$")
+assert_F(${processor} MATCHES "i[3-6]86$")
+
+# logical operators and parentheses
+set(A TRUE)
+set(B FALSE)
+set(C TRUE)
+assert_F(B OR B)
+assert_F(A AND B)
+assert_T(A AND (B OR C))
+assert_T((A AND B) OR C)
+assert_T((A AND B) OR (NOT B AND C))
+assert_F(NOT (B OR C))
+assert_T(NOT (A AND B))
+assert_F(NOT (B OR C))
+
+# target check
+set(lib1_cpp "${CMAKE_CURRENT_BINARY_DIR}/lib1.cpp")
+file(WRITE "${lib1_cpp}" "int foo() { return 42; }")
+add_library(lib1 STATIC EXCLUDE_FROM_ALL "${lib1_cpp}")
+assert_T(TARGET lib1)
+assert_F(TARGET does_not_exist)
+
+# IN_LIST
+set(primary_colors red yellow blue)
+assert_T(yellow IN_LIST primary_colors)
+assert_F(mauve IN_LIST primary_colors)
+
+# more complex string check from a real world feature
+set(INPUT_xcb "")
+set(INPUT_xkbcommon no)
+assert_F(NOT INPUT_xcb STREQUAL '' AND ( NOT INPUT_xcb STREQUAL 'no' )
+ AND INPUT_xkbcommon STREQUAL 'no')
+set(INPUT_xcb no)
+set(INPUT_xkbcommon no)
+assert_F(NOT INPUT_xcb STREQUAL '' AND ( NOT INPUT_xcb STREQUAL 'no' )
+ AND INPUT_xkbcommon STREQUAL 'no')
+set(INPUT_xcb yes)
+set(INPUT_xkbcommon no)
+assert_T(NOT INPUT_xcb STREQUAL '' AND ( NOT INPUT_xcb STREQUAL 'no' )
+ AND INPUT_xkbcommon STREQUAL 'no')
+set(INPUT_xcb no)
+set(INPUT_xkbcommon yes)
+assert_F(NOT INPUT_xcb STREQUAL '' AND ( NOT INPUT_xcb STREQUAL 'no' )
+ AND INPUT_xkbcommon STREQUAL 'no')
+
+set(FEATURE_shared ON)
+set(FEATURE_debug ON)
+set(FEATURE_debug_and_release OFF)
+set(FEATURE_force_debug_info OFF)
+set(TEST_separate_debug_info ON)
+assert_T(
+ ( FEATURE_shared )
+ AND ( FEATURE_debug OR FEATURE_debug_and_release OR FEATURE_force_debug_info )
+ AND ( MSVC OR APPLE OR TEST_separate_debug_info )
+)
diff --git a/tests/auto/cmake/test_dbus_module/CMakeLists.txt b/tests/auto/cmake/test_dbus_module/CMakeLists.txt
index 2698d9fcc8..014aae974c 100644
--- a/tests/auto/cmake/test_dbus_module/CMakeLists.txt
+++ b/tests/auto/cmake/test_dbus_module/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_dbus_module)
diff --git a/tests/auto/cmake/test_dbus_module/mydbusobject.cpp b/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
index 40e2ae0b41..c9420812b4 100644
--- a/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
+++ b/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mydbusobject.h"
#include "mydbusobjectadaptor.h"
diff --git a/tests/auto/cmake/test_dbus_module/mydbusobject.h b/tests/auto/cmake/test_dbus_module/mydbusobject.h
index 5a2c69cdae..8a95c99f04 100644
--- a/tests/auto/cmake/test_dbus_module/mydbusobject.h
+++ b/tests/auto/cmake/test_dbus_module/mydbusobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYDBUSOBJECT_H
#define MYDBUSOBJECT_H
diff --git a/tests/auto/cmake/test_dependent_modules/CMakeLists.txt b/tests/auto/cmake/test_dependent_modules/CMakeLists.txt
index 3f5e7974a6..47ced6ccda 100644
--- a/tests/auto/cmake/test_dependent_modules/CMakeLists.txt
+++ b/tests/auto/cmake/test_dependent_modules/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_dependent_modules)
diff --git a/tests/auto/cmake/test_dependent_modules/mywidget.cpp b/tests/auto/cmake/test_dependent_modules/mywidget.cpp
index 67cda1c329..da7f51d286 100644
--- a/tests/auto/cmake/test_dependent_modules/mywidget.cpp
+++ b/tests/auto/cmake/test_dependent_modules/mywidget.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mywidget.h"
#include "ui_mywidget.h"
diff --git a/tests/auto/cmake/test_dependent_modules/mywidget.h b/tests/auto/cmake/test_dependent_modules/mywidget.h
index dfa65a8503..4517670b56 100644
--- a/tests/auto/cmake/test_dependent_modules/mywidget.h
+++ b/tests/auto/cmake/test_dependent_modules/mywidget.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYWIDGET_H
#define MYWIDGET_H
diff --git a/tests/auto/cmake/test_egl_lib/main.cpp b/tests/auto/cmake/test_egl_lib/main.cpp
index b4f937b380..b5faa46dd3 100644
--- a/tests/auto/cmake/test_egl_lib/main.cpp
+++ b/tests/auto/cmake/test_egl_lib/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <EGL/egl.h>
diff --git a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
new file mode 100644
index 0000000000..10bc1fd407
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
@@ -0,0 +1 @@
+set(QT_REPO_MODULE_VERSION "6.8.0")
diff --git a/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
new file mode 100644
index 0000000000..564d23ca05
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+include(.cmake.conf)
+
+project(TestGeneratingCppExports
+ DESCRIPTION "Test of the generating of cpp exports"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+ VERSION "${QT_REPO_MODULE_VERSION}"
+)
+
+find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
+qt_internal_project_setup()
+
+qt_build_repo_begin()
+
+add_subdirectory(test_autogenerating_cpp_exports)
+add_subdirectory(test_autogenerating_cpp_exports_custom_name)
+
+qt_build_repo_post_process()
+qt_build_repo_end()
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
new file mode 100644
index 0000000000..0e446dd108
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(TestAutogeneratingCppExports
+ NO_UNITY_BUILD
+ GENERATE_CPP_EXPORTS
+ SOURCES
+ module_api.h
+ module_api.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_internal_extend_target(TestAutogeneratingCppExports
+ CONDITION GCC OR MINGW
+ COMPILE_OPTIONS
+ -fvisibility=hidden
+)
+
+add_executable(TestAutogeneratingCppExportsApp use_api.cpp)
+target_link_libraries(TestAutogeneratingCppExportsApp PRIVATE TestAutogeneratingCppExports)
+set_target_properties(TestAutogeneratingCppExportsApp PROPERTIES UNITY_BUILD OFF)
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp
new file mode 100644
index 0000000000..e77895e719
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp
@@ -0,0 +1,9 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "module_api.h"
+
+void TestApi::dummy()
+{
+ // Do nothing
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h
new file mode 100644
index 0000000000..6c8112c617
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MODULE_API_H
+#define MODULE_API_H
+
+#if 0
+#pragma qt_sync_skip_header_check
+#pragma qt_sync_stop_processing
+#endif
+
+#include <QtTestAutogeneratingCppExports/qttestautogeneratingcppexportsexports.h>
+
+struct Q_TESTAUTOGENERATINGCPPEXPORTS_EXPORT TestApi
+{
+ TestApi() = default;
+ void dummy();
+};
+
+#endif //MODULE_API_H
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp
new file mode 100644
index 0000000000..f84931300f
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp
@@ -0,0 +1,11 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "module_api.h"
+
+int main(int, char*[])
+{
+ TestApi api;
+ api.dummy();
+ return 0;
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
new file mode 100644
index 0000000000..8473979c70
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(TestAutogeneratingCppExportsCustomName
+ NO_UNITY_BUILD
+ GENERATE_CPP_EXPORTS
+ CPP_EXPORT_HEADER_BASE_NAME
+ "customname_exports"
+ SOURCES
+ module_api.h
+ module_api.cpp
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_internal_extend_target(TestAutogeneratingCppExportsCustomName
+ CONDITION GCC OR MINGW
+ COMPILE_OPTIONS
+ -fvisibility=hidden
+)
+
+add_executable(testapp2 use_api.cpp)
+target_link_libraries(testapp2 PRIVATE TestAutogeneratingCppExportsCustomName)
+set_target_properties(testapp2 PROPERTIES UNITY_BUILD OFF)
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp
new file mode 100644
index 0000000000..e77895e719
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp
@@ -0,0 +1,9 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "module_api.h"
+
+void TestApi::dummy()
+{
+ // Do nothing
+}
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h
new file mode 100644
index 0000000000..62c1b31ac4
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h
@@ -0,0 +1,20 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MODULE_API_H
+#define MODULE_API_H
+
+#if 0
+#pragma qt_sync_skip_header_check
+#pragma qt_sync_stop_processing
+#endif
+
+#include <QtTestAutogeneratingCppExportsCustomName/customname_exports.h>
+
+struct Q_TESTAUTOGENERATINGCPPEXPORTSCUSTOMNAME_EXPORT TestApi
+{
+ TestApi() = default;
+ void dummy();
+};
+
+#endif //MODULE_API_H
diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp
new file mode 100644
index 0000000000..f84931300f
--- /dev/null
+++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp
@@ -0,0 +1,11 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "module_api.h"
+
+int main(int, char*[])
+{
+ TestApi api;
+ api.dummy();
+ return 0;
+}
diff --git a/tests/auto/cmake/test_global_promotion/CMakeLists.txt b/tests/auto/cmake/test_global_promotion/CMakeLists.txt
new file mode 100644
index 0000000000..24b2eacaf1
--- /dev/null
+++ b/tests/auto/cmake/test_global_promotion/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(global_promotion)
+
+add_subdirectory(subdir_with_local_qt)
+add_subdirectory(subdir_with_global_qt)
+
+set(file_path "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+file(GENERATE OUTPUT "${file_path}" CONTENT "int main() { return 0; }")
+add_executable(exe main.cpp)
+
+# The Qt targets found in the 2nd child directory scope should be available in this scope.
+target_link_libraries(exe PRIVATE lib_global_qt)
diff --git a/tests/auto/cmake/test_global_promotion/subdir_with_global_qt/CMakeLists.txt b/tests/auto/cmake/test_global_promotion/subdir_with_global_qt/CMakeLists.txt
new file mode 100644
index 0000000000..26e3d6e025
--- /dev/null
+++ b/tests/auto/cmake/test_global_promotion/subdir_with_global_qt/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+message(STATUS "Entered subdir_with_global_qt subdirectory")
+
+set(file_path "${CMAKE_CURRENT_BINARY_DIR}/lib.cpp")
+file(GENERATE OUTPUT "${file_path}" CONTENT "int foo() { return 42; }")
+add_library(lib_global_qt STATIC "${file_path}")
+
+# These Qt targets will be available in all scopes of the project.
+# The previous local targets are simply shadowed.
+set(QT_PROMOTE_TO_GLOBAL_TARGETS ON)
+find_package(Qt6 REQUIRED COMPONENTS Gui)
+
+target_link_libraries(lib_global_qt PRIVATE Qt6::Gui)
+
+message(STATUS "Exiting subdir_with_global_qt subdirectory")
diff --git a/tests/auto/cmake/test_global_promotion/subdir_with_local_qt/CMakeLists.txt b/tests/auto/cmake/test_global_promotion/subdir_with_local_qt/CMakeLists.txt
new file mode 100644
index 0000000000..820282b7c1
--- /dev/null
+++ b/tests/auto/cmake/test_global_promotion/subdir_with_local_qt/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+message(STATUS "Entered subdir_with_local_qt subdirectory")
+
+set(file_path "${CMAKE_CURRENT_BINARY_DIR}/lib.cpp")
+file(GENERATE OUTPUT "${file_path}" CONTENT "int foo() { return 42; }")
+add_library(lib_local_qt STATIC "${file_path}")
+
+# These Qt targets will be local to this directory scope.
+find_package(Qt6 REQUIRED COMPONENTS Gui)
+
+target_link_libraries(lib_local_qt PRIVATE Qt6::Gui)
+
+message(STATUS "Exiting subdir_with_local_qt subdirectory")
diff --git a/tests/auto/cmake/test_import_plugins/CMakeLists.txt b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
index a793fe211d..5f6d629c20 100644
--- a/tests/auto/cmake/test_import_plugins/CMakeLists.txt
+++ b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
@@ -1,111 +1,180 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.16)
project(import_plugins_advanced)
enable_testing()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
- include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
-endif()
+find_package(Qt6 COMPONENTS REQUIRED MockPlugins1 MockPlugins2)
+# MockPlugins3 package is automatically found by the find_dependency call in
+# QMock5PluginConfig.cmake which depends on MockPlugins3.
+# QMock5Plugin itself is loaded by QtMockPlugins1Plugins.cmake, so via QtMockPlugins1Config.cmake.
+
+function(create_test_executable target)
+ cmake_parse_arguments(arg "FINALIZER_MODE;QT_WRAPPER" "" "ADD_EXECUTABLE_ARGS" ${ARGN})
-# Need to find Qt5Core explicitly because the MockPlugins1 and MockPlugins2 config files
-# are in a different directory (the source dir) when doing a standalone tests build,
-# whereas Core is in the installed directory, and due to NO_DEFAULT_PATH being used
-# for the Core dependency call in Qt5MockPlugins, Core would not be found in the source
-# dir.
-find_package(Qt5 COMPONENTS Core REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
-get_target_property(qt_is_static Qt5::Core TYPE)
-
-# For a similar reason, we need to find the MockPlugins packages not via COMPONENTS argument,
-# but directly, because the location of Qt5Config.cmake is in the installed dir, while
-# the MockPlugins are in the source dir, and Qt5Config only looks for packages relative
-# to its own location.
-# The packages are still successfuly found, because the CMAKE_PREFIX_PATH populated by qmake
-# contains both the installed Qt dir, and the Qt source dir.
-find_package(Qt5MockPlugins1 REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
-find_package(Qt5MockPlugins2 REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
-
-function(create_test_executable TARGET_NAME)
- set(CHECK_FILE ${CMAKE_BINARY_DIR}/${TARGET_NAME}_check.cpp)
+ set(target_name_adjusted "${target}")
+ if(arg_FINALIZER_MODE)
+ set(target_name_adjusted "${target}_finalizer")
+ endif()
+
+ set(CHECK_FILE ${CMAKE_BINARY_DIR}/${target_name_adjusted}_check.cpp)
set(EXPECTED_PLUGINS)
- foreach(_p ${ARGN})
+ foreach(_p ${arg_UNPARSED_ARGUMENTS})
string(APPEND EXPECTED_PLUGINS " \"${_p}\",\n")
endforeach()
configure_file("${CMAKE_SOURCE_DIR}/check.cpp.in" ${CHECK_FILE})
- add_executable(${TARGET_NAME} main.cpp ${CHECK_FILE})
- target_link_libraries(${TARGET_NAME} Qt5::MockPlugins1)
- add_test(test_${TARGET_NAME} ${TARGET_NAME})
+ set(add_executable_args ${target_name_adjusted} main.cpp ${CHECK_FILE}
+ ${arg_ADD_EXECUTABLE_ARGS})
+
+ if(arg_QT_WRAPPER)
+ qt_add_executable(${add_executable_args})
+ else()
+ add_executable(${add_executable_args})
+ endif()
+ target_link_libraries(${target_name_adjusted} PRIVATE Qt6::MockPlugins1)
+ add_test(test_${target_name_adjusted} ${target_name_adjusted})
+
+ if(arg_FINALIZER_MODE)
+ set(finalizer_mode_state "ENABLE")
+ else()
+ set(finalizer_mode_state "DISABLE")
+ endif()
+
+ qt_set_finalizer_mode(${target_name_adjusted} ${finalizer_mode_state} MODES static_plugins)
+ set(target ${target_name_adjusted} PARENT_SCOPE)
endfunction()
-create_test_executable(default QMock1Plugin QMock2Plugin)
-# No call to qt5_import_plugins() for the default
-
-# TODO This test is known to fail because CMake currently doesn't have a way to
-# implement its own equivalent of the PLUGIN_EXTENDS mechanism at generate-
-# time (meaning a library only gets linked if a set of other libraries are
-# *also* linked.) CMake 3.14 or beyond may have such a mechanism, but until
-# then, this test is expected to fail, because QMock3Plugin is not being
-# linked even though MockPlugins2 is present.
-create_test_executable(default_link QMock1Plugin QMock2Plugin QMock3Plugin)
-target_link_libraries(default_link Qt5::MockPlugins2)
-set_property(TEST test_default_link PROPERTY DISABLED 1)
-# No call to qt5_import_plugins() for the default
-
-create_test_executable(manual QMock1Plugin QMock2Plugin QMock3Plugin QMock4Plugin)
-qt5_import_plugins(manual
- INCLUDE Qt5::QMock3Plugin Qt5::QMock4Plugin
-)
+# No call to qt_import_plugins() for the default case.
+create_test_executable(default
+ QMock1Plugin QMock2Plugin
-create_test_executable(manual_genex QMock1Plugin QMock2Plugin QMock3Plugin)
-qt5_import_plugins(manual_genex
- INCLUDE $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
+ QMock3Plugin # TODO: Should not be linked based on .pro file, see QTBUG-93501
+ ${import_mode}
)
-create_test_executable(blacklist QMock1Plugin)
-qt5_import_plugins(blacklist
- EXCLUDE Qt5::QMock2Plugin Qt5::QMock3Plugin
+# No call to qt_import_plugins() for the default_link case.
+create_test_executable(default_link QMock1Plugin QMock2Plugin
+
+ # TODO: in qmake QMock3Plugin should only be linked if the executable depends on MockPlugins2
+ # module (based on .pro file PLUGIN_EXTENDS). Here it's accidentally linked because
+ # we're missing PLUGIN_EXTENDS information in CMake land. Thus it's considered
+ # a default plugin which is linked regardless of whether MockPlugins2 is linked.
+ # It's possible the qmake behavior is also wrong, because the qmake qt5 test seems to
+ # expect to link the plugin if both MockPlugins1 AND MockPlugins2 are linked, but qt.pf
+ # suggests that MockPlugins1 OR MockPlugins2 is sufficient to link the plugin, not both.
+ # See QTBUG-93501
+ QMock3Plugin
+ ${import_mode}
)
+target_link_libraries(${target} PRIVATE Qt6::MockPlugins2)
+
+# Check that both regular and finalizer mode plugin importing pulls in the same set of plugins.
+# In regular mode, qt_finalize_target won't execute the finalizer plugin importing, because
+# we opt out via qt_set_finalizer_mode(target DISABLE MODES static_plugins).
+foreach(import_mode "" "FINALIZER_MODE")
+ create_test_executable(manual QMock1Plugin QMock2Plugin QMock3Plugin QMock4Plugin
+ ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE Qt6::QMock3Plugin Qt6::QMock4Plugin
+ )
+ qt_finalize_target(${target})
-create_test_executable(blacklist_genex QMock1Plugin)
-qt5_import_plugins(blacklist_genex
- EXCLUDE $<1:Qt5::QMock2Plugin> $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock1Plugin>
-)
+ create_test_executable(manual_genex QMock1Plugin QMock2Plugin QMock3Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock4Plugin>
+ )
+ qt_finalize_target(${target})
-create_test_executable(override QMock3Plugin QMock4Plugin)
-qt5_import_plugins(override
- INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin Qt5::QMock4Plugin
-)
+ create_test_executable(blacklist QMock1Plugin ${import_mode})
+ qt_import_plugins(${target}
+ EXCLUDE Qt6::QMock2Plugin Qt6::QMock3Plugin
+ )
+ qt_finalize_target(${target})
-create_test_executable(override_genex QMock3Plugin)
-qt5_import_plugins(override_genex
- INCLUDE_BY_TYPE mockplugin $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
-)
+ create_test_executable(blacklist_genex QMock1Plugin ${import_mode})
+ qt_import_plugins(${target}
+ EXCLUDE $<1:Qt6::QMock2Plugin> $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock1Plugin>
+ )
+ qt_finalize_target(${target})
-create_test_executable(override_mix QMock2Plugin QMock3Plugin)
-qt5_import_plugins(override_mix
- INCLUDE Qt5::QMock2Plugin
- INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin
-)
+ create_test_executable(override QMock3Plugin QMock4Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock3Plugin Qt6::QMock4Plugin
+ )
+ qt_finalize_target(${target})
-if(NOT WIN32)
- # Compiling an empty static array fails on Windows.
- create_test_executable(none)
- qt5_import_plugins(none
+ create_test_executable(override_genex QMock3Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE_BY_TYPE mockplugin $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock4Plugin>
+ )
+ qt_finalize_target(${target})
+
+ create_test_executable(override_mix QMock2Plugin QMock3Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE Qt6::QMock2Plugin
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock3Plugin
+ )
+ qt_finalize_target(${target})
+
+ if(NOT WIN32)
+ # Compiling an empty static array fails on Windows.
+ create_test_executable(none ${import_mode})
+ qt_import_plugins(${target}
+ EXCLUDE_BY_TYPE mockplugin
+ )
+ qt_finalize_target(${target})
+ endif()
+
+ create_test_executable(none_mix QMock3Plugin QMock4Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE Qt6::QMock3Plugin Qt6::QMock4Plugin
EXCLUDE_BY_TYPE mockplugin
)
-endif()
+ qt_finalize_target(${target})
-create_test_executable(none_mix QMock3Plugin QMock4Plugin)
-qt5_import_plugins(none_mix
- INCLUDE Qt5::QMock3Plugin Qt5::QMock4Plugin
- EXCLUDE_BY_TYPE mockplugin
-)
+ # QMock5Plugin links against the Qt::MockPlugins3 module, which provides the default plugin
+ # QMock6Plugin which is why it is pulled in.
+ create_test_executable(recursive QMock5Plugin QMock6Plugin ${import_mode})
+ qt_import_plugins(${target}
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock5Plugin
+ )
+ qt_finalize_target(${target})
+endforeach()
-create_test_executable(recursive QMock5Plugin QMock6Plugin)
-qt5_import_plugins(recursive
- INCLUDE_BY_TYPE mockplugin Qt5::QMock5Plugin
-)
+# No call to qt_finalize_target() in finalizer mode means nothing will be
+# linked.
+if(NOT WIN32)
+ # Compiling an empty static array fails on Windows.
+ create_test_executable(default_finalizer_missing_import_call FINALIZER_MODE)
+endif()
+
+# Empty call to qt_import_plugins() in finalizer mode means default plugins are linked.
+create_test_executable(default_finalizer
+ QMock1Plugin QMock2Plugin
+ QMock3Plugin # TODO: Should not be linked based on .pro file, see QTBUG-93501
+ FINALIZER_MODE)
+qt_import_plugins(${target})
+qt_finalize_target(${target})
+
+# Check that plugin importing with the qt_add_executable wrapper and manual finalization mode works.
+create_test_executable(default_qt_add_executable_manually_finalized
+ QMock1Plugin QMock2Plugin
+ QMock3Plugin # TODO: Should not be linked based on .pro file, see QTBUG-93501
+ FINALIZER_MODE QT_WRAPPER
+ ADD_EXECUTABLE_ARGS MANUAL_FINALIZATION)
+qt_finalize_target(${target})
+
+# Check that plugin importing with automatic deferred finalization works when the CMake version is
+# high enough.
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+ create_test_executable(default_qt_add_executable_auto_finalized
+ QMock1Plugin QMock2Plugin
+ QMock3Plugin # TODO: Should not be linked based on .pro file, see QTBUG-93501
+ FINALIZER_MODE QT_WRAPPER)
+endif()
diff --git a/tests/auto/cmake/test_import_plugins/check.cpp.in b/tests/auto/cmake/test_import_plugins/check.cpp.in
index df6ea03d2d..6441ba4ad9 100644
--- a/tests/auto/cmake/test_import_plugins/check.cpp.in
+++ b/tests/auto/cmake/test_import_plugins/check.cpp.in
@@ -5,4 +5,4 @@ QString expectedPlugins[] = {
@EXPECTED_PLUGINS@
};
-std::size_t numExpectedPlugins = sizeof(expectedPlugins) / sizeof(numExpectedPlugins);
+std::size_t numExpectedPlugins = sizeof(expectedPlugins) / sizeof(*expectedPlugins);
diff --git a/tests/auto/cmake/test_import_plugins/main.cpp b/tests/auto/cmake/test_import_plugins/main.cpp
index 2918d557d9..69293f3abd 100644
--- a/tests/auto/cmake/test_import_plugins/main.cpp
+++ b/tests/auto/cmake/test_import_plugins/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 Kitware, Inc.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 Kitware, Inc.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QList>
#include <QPluginLoader>
@@ -77,7 +30,7 @@ int main(int argc, char **argv)
std::cerr << "Loaded plugins do not match what was expected!" << std::endl
<< "Expected plugins:" << std::endl;
- QList<QString> expectedPluginList = expectedPluginSet.toList();
+ QList<QString> expectedPluginList = expectedPluginSet.values();
expectedPluginList.sort();
for (QString plugin : expectedPluginList) {
std::cerr << (actualPluginSet.contains(plugin) ? " " : "- ")
@@ -86,7 +39,7 @@ int main(int argc, char **argv)
std::cerr << std::endl << "Actual plugins:" << std::endl;
- QList<QString> actualPluginList = actualPluginSet.toList();
+ QList<QString> actualPluginList = actualPluginSet.values();
actualPluginList.sort();
for (QString plugin : actualPluginList) {
std::cerr << (expectedPluginSet.contains(plugin) ? " " : "+ ")
diff --git a/tests/auto/cmake/test_interface/CMakeLists.txt b/tests/auto/cmake/test_interface/CMakeLists.txt
index 0cae16668e..7028b41f7b 100644
--- a/tests/auto/cmake/test_interface/CMakeLists.txt
+++ b/tests/auto/cmake/test_interface/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_interface)
@@ -14,23 +17,15 @@ add_executable(test_interface_exe WIN32 main.cpp mainwindow.cpp)
# link explicitly to Qt::WinMain.
target_link_libraries(test_interface_exe Qt::Widgets)
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
- "
-#include <QString>
-#include <QWidget>
-
-int main(int,char**) { QWidget w; w.show(); return 0; }
-"
-)
-
# Fix try_compile to inherit the parent configuration.
set(CMAKE_TRY_COMPILE_CONFIGURATION "${CMAKE_BUILD_TYPE}")
-# The try_compile works because Qt::Widgets is listed in the LINK_LIBRARIES,
-# which causes the includes, defines and appropriate PIC flag to be used.
-try_compile(_TRY_COMPILE_RES "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test"
- "${CMAKE_CURRENT_BINARY_DIR}/try_compile-test.cpp"
- LINK_LIBRARIES Qt::Widgets
+# Can't use source file based try_compile, because it doesn't handle object libraries
+# referenced in generator expressions properly.
+try_compile(_TRY_COMPILE_RES
+ "${CMAKE_CURRENT_BINARY_DIR}/widget_test"
+ "${CMAKE_CURRENT_SOURCE_DIR}/widget_test"
+ widget_test
OUTPUT_VARIABLE TC_OV
)
diff --git a/tests/auto/cmake/test_interface/main.cpp b/tests/auto/cmake/test_interface/main.cpp
index 491c7bf016..56b442a4ce 100644
--- a/tests/auto/cmake/test_interface/main.cpp
+++ b/tests/auto/cmake/test_interface/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QApplication>
diff --git a/tests/auto/cmake/test_interface/mainwindow.cpp b/tests/auto/cmake/test_interface/mainwindow.cpp
index 56bf81611a..2fec6400f6 100644
--- a/tests/auto/cmake/test_interface/mainwindow.cpp
+++ b/tests/auto/cmake/test_interface/mainwindow.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "mainwindow.h"
diff --git a/tests/auto/cmake/test_interface/mainwindow.h b/tests/auto/cmake/test_interface/mainwindow.h
index 2dd52efd01..345c4f69e9 100644
--- a/tests/auto/cmake/test_interface/mainwindow.h
+++ b/tests/auto/cmake/test_interface/mainwindow.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
new file mode 100644
index 0000000000..dd4c8fff28
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_interface_try_compile)
+
+find_package(Qt6Widgets)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(test_interface_try_compile_exe main.cpp)
+target_link_libraries(test_interface_try_compile_exe Qt::Widgets)
+
diff --git a/tests/auto/cmake/test_interface/widget_test/main.cpp b/tests/auto/cmake/test_interface/widget_test/main.cpp
new file mode 100644
index 0000000000..e6a8ab5fe9
--- /dev/null
+++ b/tests/auto/cmake/test_interface/widget_test/main.cpp
@@ -0,0 +1,4 @@
+#include <QString>
+#include <QWidget>
+
+int main(int, char**) { QWidget w; w.show(); return 0; }
diff --git a/tests/auto/cmake/test_interface_link_libraries/CMakeLists.txt b/tests/auto/cmake/test_interface_link_libraries/CMakeLists.txt
index 5853a6bcab..6a38d263cd 100644
--- a/tests/auto/cmake/test_interface_link_libraries/CMakeLists.txt
+++ b/tests/auto/cmake/test_interface_link_libraries/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_interface_link_libraries)
diff --git a/tests/auto/cmake/test_interface_link_libraries/main.cpp b/tests/auto/cmake/test_interface_link_libraries/main.cpp
index b035460587..7d4ca031db 100644
--- a/tests/auto/cmake/test_interface_link_libraries/main.cpp
+++ b/tests/auto/cmake/test_interface_link_libraries/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "somelib.h"
diff --git a/tests/auto/cmake/test_interface_link_libraries/somelib.cpp b/tests/auto/cmake/test_interface_link_libraries/somelib.cpp
index acb4b3fa68..de51a8e60f 100644
--- a/tests/auto/cmake/test_interface_link_libraries/somelib.cpp
+++ b/tests/auto/cmake/test_interface_link_libraries/somelib.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "somelib.h"
diff --git a/tests/auto/cmake/test_interface_link_libraries/somelib.h b/tests/auto/cmake/test_interface_link_libraries/somelib.h
index 9cad2931af..d2f0cfd554 100644
--- a/tests/auto/cmake/test_interface_link_libraries/somelib.h
+++ b/tests/auto/cmake/test_interface_link_libraries/somelib.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef SOMELIB_H
#define SOMELIB_H
diff --git a/tests/auto/cmake/test_json_plugin_includes/CMakeLists.txt b/tests/auto/cmake/test_json_plugin_includes/CMakeLists.txt
index d1b03cfc70..15ea1ccadf 100644
--- a/tests/auto/cmake/test_json_plugin_includes/CMakeLists.txt
+++ b/tests/auto/cmake/test_json_plugin_includes/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_json_plugin_includes)
diff --git a/tests/auto/cmake/test_json_plugin_includes/plugin.cpp b/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
index c9626d6433..5554fe737a 100644
--- a/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
+++ b/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "plugin.h"
diff --git a/tests/auto/cmake/test_json_plugin_includes/plugin.h b/tests/auto/cmake/test_json_plugin_includes/plugin.h
index 79ec252734..7e3e9b4569 100644
--- a/tests/auto/cmake/test_json_plugin_includes/plugin.h
+++ b/tests/auto/cmake/test_json_plugin_includes/plugin.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef JSON_TEST_PLUGIN_H
#define JSON_TEST_PLUGIN_H
diff --git a/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt b/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
index ed765ee71c..f9ca294bd2 100644
--- a/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
+++ b/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_moc_macro_target)
@@ -11,7 +14,14 @@ qt_generate_moc(main_gen_test.cpp
"${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc"
TARGET QtGenerateMacroTest
)
+list(APPEND CMAKE_AUTOMOC_MACRO_NAMES MySpecialMacro)
add_executable(QtGenerateMacroTest main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc")
+get_target_property(current_macros QtGenerateMacroTest AUTOMOC_MACRO_NAMES)
+
+if(NOT "${CMAKE_AUTOMOC_MACRO_NAMES}" STREQUAL "${current_macros}")
+ message(FATAL_ERROR "Expected ${CMAKE_AUTOMOC_MACRO_NAMES} but received ${current_macros}")
+endif()
+
target_include_directories(QtGenerateMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
target_link_libraries(QtGenerateMacroTest PRIVATE Qt6::Core)
@@ -21,3 +31,25 @@ qt_wrap_cpp(moc_file mywrapobject.h
add_executable(QtWrapMacroTest main_wrap_test.cpp ${moc_file})
target_include_directories(QtWrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
target_link_libraries(QtWrapMacroTest PRIVATE Qt::Core)
+
+target_compile_definitions(QtWrapMacroTest PRIVATE "$<$<BOOL:TRUE>:MY_OPTION>"
+ "$<$<BOOL:TRUE>:DEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int$<COMMA> int$<ANGLE-R> &i)>"
+ "DEFINE_CMDLINE_SIGNAL=void cmdlineSignal(const QMap<int, int> &i)")
+
+set(parameters_file_base "${CMAKE_CURRENT_BINARY_DIR}/moc_mywrapobject.cpp_parameters")
+# check if generator is multi-config
+if(CMAKE_CONFIGURATION_TYPES)
+ set(parameters_file "${parameters_file_base}_$<CONFIG>")
+else()
+ if(NOT CMAKE_BUILD_TYPE STREQUAL "")
+ set(parameters_file "${parameters_file_base}_${CMAKE_BUILD_TYPE}")
+ else()
+ set(parameters_file "${parameters_file_base}")
+ endif()
+endif()
+
+add_custom_command(TARGET QtWrapMacroTest
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} "-DPARAMETERS_FILE_PATH=${parameters_file}" -P check_moc_parameters.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+)
diff --git a/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
new file mode 100644
index 0000000000..4ca8fab119
--- /dev/null
+++ b/tests/auto/cmake/test_moc_macro_target/check_moc_parameters.cmake
@@ -0,0 +1,15 @@
+
+function(check_parameters file_path)
+ file(READ ${file_path} file_content)
+ foreach(compile_option IN ITEMS "-DDEFINE_CMDLINE_SIGNAL" "-DMY_OPTION")
+ string(REGEX MATCHALL "${compile_option}" matches ${file_content})
+ list(LENGTH matches matches_length)
+ if(matches_length GREATER 1)
+ message(FATAL_ERROR "${compile_option} is defined multiple times in ${file_path}")
+ elseif(matches_length EQUAL 0)
+ message(FATAL_ERROR "${compile_option} is not defined in ${file_path}")
+ endif()
+ endforeach()
+endfunction()
+
+check_parameters(${PARAMETERS_FILE_PATH})
diff --git a/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h b/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
index 3d5dbf98ef..3c18c9a10d 100644
--- a/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
+++ b/tests/auto/cmake/test_moc_macro_target/interface/myinterface.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYINTERFACE_H
#define MYINTERFACE_H
diff --git a/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp b/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
index 3e6c4acd4e..ef58aa025a 100644
--- a/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
+++ b/tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
diff --git a/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp b/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
index 002422eec4..bf4b6193fe 100644
--- a/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
+++ b/tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
diff --git a/tests/auto/cmake/test_moc_macro_target/mywrapobject.h b/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
index a4be007110..28030a5832 100644
--- a/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
+++ b/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYWRAPOBJECT_H
#define MYWRAPOBJECT_H
diff --git a/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt b/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt
index adf7de5640..1b50c204ca 100644
--- a/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt
+++ b/tests/auto/cmake/test_multiple_find_package/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_multiple_find_package)
diff --git a/tests/auto/cmake/test_multiple_find_package/main.cpp b/tests/auto/cmake/test_multiple_find_package/main.cpp
index 926dee98b3..820a550917 100644
--- a/tests/auto/cmake/test_multiple_find_package/main.cpp
+++ b/tests/auto/cmake/test_multiple_find_package/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QString>
diff --git a/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt b/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt
index 61a273424e..abf9abf8a7 100644
--- a/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt
+++ b/tests/auto/cmake/test_multiple_find_package/subdir1/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
find_package(Qt6Core REQUIRED)
diff --git a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
index 0fef37da3d..b5672b4393 100644
--- a/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
+++ b/tests/auto/cmake/test_opengl_lib/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_opengl_lib)
diff --git a/tests/auto/cmake/test_opengl_lib/main.cpp b/tests/auto/cmake/test_opengl_lib/main.cpp
index e3d9b6af15..b29d11f667 100644
--- a/tests/auto/cmake/test_opengl_lib/main.cpp
+++ b/tests/auto/cmake/test_opengl_lib/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qglobal.h>
diff --git a/tests/auto/cmake/test_platform_defs_include/CMakeLists.txt b/tests/auto/cmake/test_platform_defs_include/CMakeLists.txt
index 110ae472da..ab3a935894 100644
--- a/tests/auto/cmake/test_platform_defs_include/CMakeLists.txt
+++ b/tests/auto/cmake/test_platform_defs_include/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_platform_defs_include)
diff --git a/tests/auto/cmake/test_platform_defs_include/main.cpp b/tests/auto/cmake/test_platform_defs_include/main.cpp
index fcfd3b4718..30d2e2065a 100644
--- a/tests/auto/cmake/test_platform_defs_include/main.cpp
+++ b/tests/auto/cmake/test_platform_defs_include/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qplatformdefs.h"
diff --git a/tests/auto/cmake/test_plugin_shared_static_flavor.cmake b/tests/auto/cmake/test_plugin_shared_static_flavor.cmake
new file mode 100644
index 0000000000..ffe5fb5447
--- /dev/null
+++ b/tests/auto/cmake/test_plugin_shared_static_flavor.cmake
@@ -0,0 +1,27 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+_qt_internal_test_expect_pass(test_plugin_shared_static_flavor
+ TESTNAME test_plugin_flavor_static
+ BUILD_OPTIONS
+ "-DPLUGIN_OPTIONS=STATIC"
+ "-DEXPECTED_PLUGIN_TARGET_TYPE=STATIC_LIBRARY")
+
+_qt_internal_test_expect_pass(test_plugin_shared_static_flavor
+ TESTNAME test_plugin_flavor_shared
+ BUILD_OPTIONS
+ "-DPLUGIN_OPTIONS=SHARED"
+ "-DEXPECTED_PLUGIN_TARGET_TYPE=MODULE_LIBRARY")
+
+if(QT6_IS_SHARED_LIBS_BUILD)
+ set(expected_plugin_target_type "MODULE_LIBRARY")
+else()
+ set(expected_plugin_target_type "STATIC_LIBRARY")
+endif()
+
+# Check default computed value when no explicit option is set.
+_qt_internal_test_expect_pass(test_plugin_shared_static_flavor
+ TESTNAME test_plugin_flavor_derived_from_qt_type
+ BUILD_OPTIONS
+ "-DPLUGIN_OPTIONS="
+ "-DEXPECTED_PLUGIN_TARGET_TYPE=${expected_plugin_target_type}")
diff --git a/tests/auto/cmake/test_plugin_shared_static_flavor/CMakeLists.txt b/tests/auto/cmake/test_plugin_shared_static_flavor/CMakeLists.txt
new file mode 100644
index 0000000000..fda0c69d07
--- /dev/null
+++ b/tests/auto/cmake/test_plugin_shared_static_flavor/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_plugin_flavor)
+
+if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+endif()
+
+find_package(Qt6Core REQUIRED HINTS ${Qt6Tests_PREFIX_PATH})
+
+qt6_add_plugin(test_plugin ${PLUGIN_OPTIONS})
+
+set(plugin_source_path "${CMAKE_CURRENT_BINARY_DIR}/plugin.cpp")
+file(GENERATE OUTPUT "${plugin_source_path}" CONTENT "int foo() {return 0;}")
+target_sources(test_plugin PRIVATE "${plugin_source_path}")
+
+get_target_property(plugin_target_type test_plugin TYPE)
+
+if(NOT EXPECTED_PLUGIN_TARGET_TYPE)
+ message(FATAL_ERROR "No value given for EXPECTED_PLUGIN_TARGET_TYPE variable")
+endif()
+
+if(NOT plugin_target_type STREQUAL "${EXPECTED_PLUGIN_TARGET_TYPE}")
+ set(info "")
+ list(APPEND info "PLUGIN_OPTIONS: ${PLUGIN_OPTIONS}")
+ list(APPEND info "QT6_IS_SHARED_LIBS_BUILD: ${QT6_IS_SHARED_LIBS_BUILD}")
+ list(APPEND info "EXPECTED_PLUGIN_TARGET_TYPE: ${EXPECTED_PLUGIN_TARGET_TYPE}")
+ list(JOIN info "\n" info)
+ message(FATAL_ERROR
+ "Computed plugin target type '${plugin_target_type}' did not match expected type '${EXPECTED_PLUGIN_TARGET_TYPE}'\n${info}")
+endif()
diff --git a/tests/auto/cmake/test_plugins/CMakeLists.txt b/tests/auto/cmake/test_plugins/CMakeLists.txt
index b571be4954..5b6c4eea4e 100644
--- a/tests/auto/cmake/test_plugins/CMakeLists.txt
+++ b/tests/auto/cmake/test_plugins/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_plugins)
diff --git a/tests/auto/cmake/test_private_includes/CMakeLists.txt b/tests/auto/cmake/test_private_includes/CMakeLists.txt
index 6ad27832d2..d4ba8ab888 100644
--- a/tests/auto/cmake/test_private_includes/CMakeLists.txt
+++ b/tests/auto/cmake/test_private_includes/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_private_includes)
diff --git a/tests/auto/cmake/test_private_includes/main.cpp b/tests/auto/cmake/test_private_includes/main.cpp
index 83146dd7d9..6dc90fbae0 100644
--- a/tests/auto/cmake/test_private_includes/main.cpp
+++ b/tests/auto/cmake/test_private_includes/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <QScreen>
diff --git a/tests/auto/cmake/test_private_targets/CMakeLists.txt b/tests/auto/cmake/test_private_targets/CMakeLists.txt
index bec103cb87..72e06b044c 100644
--- a/tests/auto/cmake/test_private_targets/CMakeLists.txt
+++ b/tests/auto/cmake/test_private_targets/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_private_targets)
diff --git a/tests/auto/cmake/test_private_targets/main.cpp b/tests/auto/cmake/test_private_targets/main.cpp
index 40dc4c243c..4566fd6ce6 100644
--- a/tests/auto/cmake/test_private_targets/main.cpp
+++ b/tests/auto/cmake/test_private_targets/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Stephen Kelly <steveire@gmail.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 Stephen Kelly <steveire@gmail.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt b/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt
new file mode 100644
index 0000000000..e7b35b332f
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/CMakeLists.txt
@@ -0,0 +1,123 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_qt_add_resources_rebuild)
+
+set(test_project_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/sample")
+set(test_project_build_dir "${CMAKE_CURRENT_BINARY_DIR}/build_sample")
+
+# Make sure that file paths are 'real' paths
+get_filename_component(test_project_source_dir "${test_project_source_dir}" REALPATH)
+get_filename_component(test_project_build_dir "${test_project_build_dir}" REALPATH)
+
+file(REMOVE_RECURSE "${test_project_build_dir}")
+file(MAKE_DIRECTORY "${test_project_build_dir}")
+
+# For access to _qt_internal_get_cmake_test_configure_options
+find_package(Qt6 COMPONENTS Core REQUIRED)
+include("${_Qt6CTestMacros}")
+
+set(indent " ")
+list(APPEND CMAKE_MESSAGE_INDENT "${indent}")
+
+function(configure_project)
+ message(STATUS "Configuring build")
+ _qt_internal_get_cmake_test_configure_options(option_list)
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+ "-G${CMAKE_GENERATOR}"
+ ${option_list}
+ -B "${test_project_build_dir}"
+ -S "${test_project_source_dir}"
+ RESULT_VARIABLE result
+ )
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to configure sample project")
+ endif()
+endfunction()
+
+function(try_build)
+ message(STATUS "Building project")
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ --build "${test_project_build_dir}"
+ RESULT_VARIABLE result
+ )
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to build test project")
+ endif()
+endfunction()
+
+function(get_target_path out_var)
+ file(STRINGS "${test_project_build_dir}/targets.txt" targets)
+ list(GET targets 0 first_target_path)
+ message(STATUS "Built target is at '${first_target_path}'")
+ set(${out_var} "${first_target_path}" PARENT_SCOPE)
+endfunction()
+
+function(get_timestamp file_path out_var)
+ message(STATUS "Getting timestamp of built target.")
+ file(TIMESTAMP "${file_path}" value "%s")
+ set(${out_var} "${value}" PARENT_SCOPE)
+endfunction()
+
+function(sleep)
+ # Avoids issues with low resolution modification times (like HFS on macOS).
+ set(seconds 2)
+ message(STATUS "Sleeping for ${seconds} seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep ${seconds})
+endfunction()
+
+function(touch_file)
+ set(input "input.ts")
+ set(input_path "${test_project_source_dir}/${input}")
+ message(STATUS "Touching ${input_path}")
+ file(TOUCH "${input_path}")
+endfunction()
+
+function(assert_timestamp_is_equal before after)
+ set(timestamps "\n${indent}Before TS: ${before}\n${indent} After TS: ${after}")
+ if("${after}" EQUAL "${before}")
+ message(STATUS "Target was not rebuilt. ${timestamps}")
+ else()
+ message(FATAL_ERROR "Target WAS rebuilt. ${timestamps}")
+ endif()
+endfunction()
+
+function(assert_timestamp_is_greater before after)
+ set(timestamps "\n${indent}Before TS: ${before}\n${indent} After TS: ${after}")
+ if("${after}" GREATER "${before}")
+ message(STATUS "Target was correctly rebuilt. ${timestamps}")
+ else()
+ message(FATAL_ERROR "Target was NOT rebuilt. ${timestamps}")
+ endif()
+endfunction()
+
+configure_project()
+try_build()
+get_target_path(target_path)
+
+# Make sure that a second build without changes doesn't rebuild the executable.
+get_timestamp("${target_path}" ts_1)
+sleep()
+try_build()
+get_timestamp("${target_path}" ts_2)
+assert_timestamp_is_equal("${ts_1}" "${ts_2}")
+
+# Touching the input file should cause rcc to rerun, then the compiler, then the linker,
+# and thus the executable timestamp should be updated.
+touch_file()
+try_build()
+get_timestamp("${target_path}" ts_3)
+assert_timestamp_is_greater("${ts_2}" "${ts_3}")
+
+# Check that building again doesn't rebuild the executable.
+sleep()
+try_build()
+get_timestamp("${target_path}" ts_4)
+assert_timestamp_is_equal("${ts_3}" "${ts_4}")
+
+list(POP_BACK CMAKE_MESSAGE_INDENT)
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
new file mode 100644
index 0000000000..0a40a948c6
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.16)
+project(sample LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core)
+
+set(source "${CMAKE_BINARY_DIR}/main.cpp")
+file(GENERATE OUTPUT "${source}" CONTENT "int main() { return 0; }")
+
+qt_add_executable(${PROJECT_NAME} ${source})
+
+# This is a poor man's implementation of qt_add_lupdate.
+set(input "${CMAKE_SOURCE_DIR}/input.ts")
+set(output "${CMAKE_BINARY_DIR}/output.qm")
+add_custom_command(
+ OUTPUT "${output}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${input}" "${output}"
+ DEPENDS "${input}"
+ VERBATIM
+)
+
+# This is where the bug happened before. Adding the target dependency properties used the target
+# as an order-only dependency, instead of depending on the actual dependency file.
+set_source_files_properties("${output}"
+ PROPERTIES _qt_resource_target_dependency "output_target")
+
+add_custom_target(output_target
+ DEPENDS "${output}"
+)
+
+qt_add_resources(${PROJECT_NAME} "res"
+ PREFIX "/"
+ BASE "${CMAKE_CURRENT_BINARY_DIR}"
+ FILES "${output}"
+)
+
+# Write out the location of the binary so its timestamp can be checked by the driving parent
+# project.
+set(target_file_out "${CMAKE_BINARY_DIR}/targets.txt")
+add_custom_target(all_built ALL
+ COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:${PROJECT_NAME}>" > "${target_file_out}"
+ VERBATIM
+)
+# Make sure the file path is written out after the executable is linked.
+add_dependencies(all_built ${PROJECT_NAME})
diff --git a/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts
new file mode 100644
index 0000000000..20a96e90c4
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_resources_rebuild/sample/input.ts
@@ -0,0 +1 @@
+bonk
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/CMakeLists.txt b/tests/auto/cmake/test_qt_extract_metatypes/CMakeLists.txt
new file mode 100644
index 0000000000..26944b1192
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/CMakeLists.txt
@@ -0,0 +1,109 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_qt_extract_metatypes VERSION 0.1 LANGUAGES CXX)
+
+set(test_project_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/test_qt_extract_metatypes_project")
+set(test_project_build_dir "${CMAKE_CURRENT_BINARY_DIR}/build_qt_extract_metatypes_test_project")
+
+# Make sure that file paths are 'real' paths
+get_filename_component(test_project_source_dir "${test_project_source_dir}" REALPATH)
+get_filename_component(test_project_build_dir "${test_project_build_dir}" REALPATH)
+
+get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
+if (CMAKE_BUILD_TYPE AND NOT is_multi_config)
+ string(TOLOWER "qt6metatypetest_${CMAKE_BUILD_TYPE}" metatypes_file_basename)
+else()
+ string(TOLOWER "qt6metatypetest" metatypes_file_basename)
+endif()
+set(meta_types_file
+ "${test_project_build_dir}/meta_types/${metatypes_file_basename}_metatypes.json")
+
+file(REMOVE_RECURSE "${test_project_build_dir}")
+file(MAKE_DIRECTORY "${test_project_build_dir}")
+
+find_package(Qt6 COMPONENTS Core REQUIRED)
+
+include("${_Qt6CTestMacros}")
+
+macro(try_build)
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ --build "${test_project_build_dir}"
+ RESULT_VARIABLE result
+ )
+ if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to build test project")
+ endif()
+endmacro()
+
+macro(copy_test_header header)
+ file(COPY "${test_project_source_dir}/testdata/${header}"
+ DESTINATION "${test_project_build_dir}")
+ file(RENAME "${test_project_build_dir}/${header}" "${test_project_build_dir}/MetaType.h")
+ file(TOUCH "${test_project_build_dir}/MetaType.h")
+endmacro()
+
+macro(check_generated_metatypes_file reference expect)
+ set(reference_meta_types_file "${test_project_source_dir}/testdata/${reference}")
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ -E compare_files "${meta_types_file}" "${reference_meta_types_file}"
+ RESULT_VARIABLE compare_result
+ )
+ if(NOT compare_result EQUAL ${expect})
+ message(FATAL_ERROR "${meta_types_file} and ${reference_meta_types_file} content differs")
+ endif()
+ unset(reference_meta_types_file)
+endmacro()
+
+copy_test_header(MetaTypeQ_OBJECT.h)
+
+_qt_internal_get_cmake_test_configure_options(option_list)
+execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+ "-G${CMAKE_GENERATOR}"
+ ${option_list}
+ -B "${test_project_build_dir}"
+ -S "${test_project_source_dir}"
+ RESULT_VARIABLE result
+)
+if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Unable to configure test project")
+endif()
+
+try_build()
+check_generated_metatypes_file(qt6metatypetest_metatypesQ_OBJECT.json 0)
+
+copy_test_header(MetaTypeQ_OBJECTandQ_PROPERTY.h)
+try_build()
+check_generated_metatypes_file(qt6metatypetest_metatypesQ_OBJECTandQ_PROPERTY.json 0)
+
+copy_test_header(MetaTypeEmpty.h)
+try_build()
+check_generated_metatypes_file(qt6metatypetest_metatypesEmpty.json 0)
+file(TIMESTAMP "${meta_types_file}" metatypes_timestamp)
+
+copy_test_header(MetaTypeEmptyWithComment.h)
+try_build()
+check_generated_metatypes_file(qt6metatypetest_metatypesEmpty.json 0)
+
+file(TIMESTAMP "${meta_types_file}" new_metatypes_timestamp)
+
+# Depending on the way how qt_extract_metatypes executes automoc it might or might not
+# change the resulting .json file content.
+set(extract_metatypes_uses_dep_files FALSE)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.17") # Requires automoc changes present only in 3.17
+ if(CMAKE_GENERATOR STREQUAL "Ninja" OR CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
+ set(extract_metatypes_uses_dep_files TRUE)
+ endif()
+endif()
+
+if(extract_metatypes_uses_dep_files)
+ if(NOT metatypes_timestamp STREQUAL new_metatypes_timestamp)
+ message(FATAL_ERROR "${meta_types_file} timestamp is changed but should not")
+ endif()
+endif()
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/CMakeLists.txt b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/CMakeLists.txt
new file mode 100644
index 0000000000..328f20aaab
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(qt_extract_metatypes_test_project VERSION 0.1 LANGUAGES CXX)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(Qt6 COMPONENTS Core REQUIRED)
+
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+qt_add_executable(MetaTypeTest
+ MetaType.cpp
+ "${CMAKE_CURRENT_BINARY_DIR}/MetaType.h"
+ main.cpp
+)
+target_include_directories(MetaTypeTest PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
+qt_extract_metatypes(MetaTypeTest)
+target_link_libraries(MetaTypeTest PRIVATE Qt6::Core)
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/MetaType.cpp b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/MetaType.cpp
new file mode 100644
index 0000000000..40fb1dffbe
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/MetaType.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "MetaType.h"
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/main.cpp b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/main.cpp
new file mode 100644
index 0000000000..b141c894ab
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/main.cpp
@@ -0,0 +1,7 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/.gitattributes b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/.gitattributes
new file mode 100644
index 0000000000..8f4efb84e5
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/.gitattributes
@@ -0,0 +1 @@
+*.json text eol=lf
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmpty.h b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmpty.h
new file mode 100644
index 0000000000..bcd7594d9a
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmpty.h
@@ -0,0 +1,10 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+#include <QObject>
+
+class MetaType : public QObject
+{
+};
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmptyWithComment.h b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmptyWithComment.h
new file mode 100644
index 0000000000..1c38ae2f5e
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmptyWithComment.h
@@ -0,0 +1,11 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+#include <QObject>
+
+class MetaType : public QObject
+{
+// Changes of no value to automoc
+};
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECT.h b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECT.h
new file mode 100644
index 0000000000..104dd6d7a9
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECT.h
@@ -0,0 +1,10 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+#include <QObject>
+
+class MetaType : public QObject
+{
+ Q_OBJECT
+};
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECTandQ_PROPERTY.h b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECTandQ_PROPERTY.h
new file mode 100644
index 0000000000..f3a9ececb7
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECTandQ_PROPERTY.h
@@ -0,0 +1,13 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#pragma once
+
+#include <QObject>
+
+class MetaType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int test READ test)
+ int test() { return 0; }
+};
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesEmpty.json b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesEmpty.json
new file mode 100644
index 0000000000..0d4f101c7a
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesEmpty.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECT.json b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECT.json
new file mode 100644
index 0000000000..9393eda2df
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECT.json
@@ -0,0 +1,19 @@
+[
+ {
+ "classes": [
+ {
+ "className": "MetaType",
+ "object": true,
+ "qualifiedClassName": "MetaType",
+ "superClasses": [
+ {
+ "access": "public",
+ "name": "QObject"
+ }
+ ]
+ }
+ ],
+ "inputFile": "MetaType.h",
+ "outputRevision": 68
+ }
+]
diff --git a/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECTandQ_PROPERTY.json b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECTandQ_PROPERTY.json
new file mode 100644
index 0000000000..f6a901952d
--- /dev/null
+++ b/tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/qt6metatypetest_metatypesQ_OBJECTandQ_PROPERTY.json
@@ -0,0 +1,34 @@
+[
+ {
+ "classes": [
+ {
+ "className": "MetaType",
+ "object": true,
+ "properties": [
+ {
+ "constant": false,
+ "designable": true,
+ "final": false,
+ "index": 0,
+ "name": "test",
+ "read": "test",
+ "required": false,
+ "scriptable": true,
+ "stored": true,
+ "type": "int",
+ "user": false
+ }
+ ],
+ "qualifiedClassName": "MetaType",
+ "superClasses": [
+ {
+ "access": "public",
+ "name": "QObject"
+ }
+ ]
+ }
+ ],
+ "inputFile": "MetaType.h",
+ "outputRevision": 68
+ }
+]
diff --git a/tests/auto/cmake/test_qt_manual_moc/CMakeLists.txt b/tests/auto/cmake/test_qt_manual_moc/CMakeLists.txt
new file mode 100644
index 0000000000..513995c4cf
--- /dev/null
+++ b/tests/auto/cmake/test_qt_manual_moc/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core)
+
+set(CMAKE_AUTOMOC FALSE)
+
+qt_manual_moc(moc_files testclass.h
+ DEFINITIONS
+ -DMY_FIRST_DEF
+ MY_SECOND_DEF
+ -DMY_THIRD_DEF=1
+ MY_FOURTH_DEF=1
+)
+
+add_custom_target(verify_testclass ALL COMMAND ${CMAKE_COMMAND}
+ "-DMOC_ARGS=moc_testclass.cpp_parameters$<$<BOOL:$<CONFIG>>:_$<CONFIG>>"
+ "-DDEFINITIONS=MY_FIRST_DEF;MY_SECOND_DEF;MY_THIRD_DEF=1;MY_FOURTH_DEF=1"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyDefines.cmake"
+ VERBATIM
+)
+
+add_library(MyInterfaceLib INTERFACE)
+target_compile_definitions(MyInterfaceLib INTERFACE -DMY_TRANSITIVE_DEF=1)
+
+add_library(MyLib SHARED testclass1.h testclass.cpp)
+target_link_libraries(MyLib PRIVATE Qt6::Core MyInterfaceLib)
+target_compile_definitions(MyLib PRIVATE
+ -DMY_FIRST_DEF
+ MY_SECOND_DEF
+ -DMY_THIRD_DEF=1
+ MY_FOURTH_DEF=1
+)
+
+add_library(MyLib2 SHARED testclass1.h testclass.cpp)
+target_link_libraries(MyLib2 PRIVATE Qt6::Core)
+target_compile_definitions(MyLib2 PRIVATE
+ -DMY_FOREIGN_DEF
+)
+
+qt_manual_moc(moc_files testclass1.h TARGETS MyLib MyLib2)
+target_sources(MyLib PRIVATE ${moc_files})
+target_sources(MyLib2 PRIVATE ${moc_files})
+
+string(JOIN ";" expected
+ "MY_FIRST_DEF"
+ "MY_SECOND_DEF"
+ "MY_THIRD_DEF=1"
+ "MY_FOURTH_DEF=1"
+ "MY_TRANSITIVE_DEF=1"
+ "MY_FOREIGN_DEF"
+)
+
+add_custom_target(verify_testclass1 ALL COMMAND ${CMAKE_COMMAND}
+ "-DMOC_ARGS=moc_testclass1.cpp_parameters$<$<BOOL:$<CONFIG>>:_$<CONFIG>>"
+ "-DDEFINITIONS=${expected}"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/VerifyDefines.cmake"
+ VERBATIM
+)
diff --git a/tests/auto/cmake/test_qt_manual_moc/VerifyDefines.cmake b/tests/auto/cmake/test_qt_manual_moc/VerifyDefines.cmake
new file mode 100644
index 0000000000..b3acedb014
--- /dev/null
+++ b/tests/auto/cmake/test_qt_manual_moc/VerifyDefines.cmake
@@ -0,0 +1,30 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+if(NOT DEFINITIONS)
+ message(FATAL_ERROR "No definitions are provided to test")
+endif()
+
+if(NOT MOC_ARGS)
+ message(FATAL_ERROR "The moc RSP file is not specified")
+endif()
+
+file(READ "${MOC_ARGS}" moc_args_data)
+
+string(REPLACE "\n" ";" moc_args_data "${moc_args_data}")
+
+foreach(def IN LISTS DEFINITIONS)
+ set(found FALSE)
+ foreach(data IN LISTS moc_args_data)
+ if(data MATCHES "^(-D)?${def}")
+ set(found TRUE)
+ break()
+ endif()
+ endforeach()
+ if(NOT found)
+ message(FATAL_ERROR "The ${def} is missing in the moc argument list:\n${moc_args_data}")
+ endif()
+endforeach()
+
diff --git a/tests/auto/cmake/test_qt_manual_moc/testclass.cpp b/tests/auto/cmake/test_qt_manual_moc/testclass.cpp
new file mode 100644
index 0000000000..5323e18136
--- /dev/null
+++ b/tests/auto/cmake/test_qt_manual_moc/testclass.cpp
@@ -0,0 +1,8 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include "testclass.h"
+
+TestClass::TestClass(QObject *parent) : QObject(parent)
+{
+
+}
diff --git a/tests/auto/cmake/test_qt_manual_moc/testclass.h b/tests/auto/cmake/test_qt_manual_moc/testclass.h
new file mode 100644
index 0000000000..84fc656f1a
--- /dev/null
+++ b/tests/auto/cmake/test_qt_manual_moc/testclass.h
@@ -0,0 +1,17 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef TESTCLASS_H
+#define TESTCLASS_H
+
+#include <QObject>
+
+class TestClass : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestClass(QObject *parent = nullptr);
+};
+
+#endif // TESTCLASS_H
diff --git a/tests/auto/cmake/test_qt_manual_moc/testclass1.h b/tests/auto/cmake/test_qt_manual_moc/testclass1.h
new file mode 100644
index 0000000000..84fc656f1a
--- /dev/null
+++ b/tests/auto/cmake/test_qt_manual_moc/testclass1.h
@@ -0,0 +1,17 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef TESTCLASS_H
+#define TESTCLASS_H
+
+#include <QObject>
+
+class TestClass : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestClass(QObject *parent = nullptr);
+};
+
+#endif // TESTCLASS_H
diff --git a/tests/auto/cmake/test_qtmainwin_library/CMakeLists.txt b/tests/auto/cmake/test_qtmainwin_library/CMakeLists.txt
index b4f3a102e2..4719d9c332 100644
--- a/tests/auto/cmake/test_qtmainwin_library/CMakeLists.txt
+++ b/tests/auto/cmake/test_qtmainwin_library/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_qtmainwin_library)
diff --git a/tests/auto/cmake/test_qtmainwin_library/myobject.cpp b/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
index ea4ebbbe3f..bb06a5bb8b 100644
--- a/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
+++ b/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "myobject.h"
diff --git a/tests/auto/cmake/test_qtmainwin_library/myobject.h b/tests/auto/cmake/test_qtmainwin_library/myobject.h
index df0e377a60..90bb75640f 100644
--- a/tests/auto/cmake/test_qtmainwin_library/myobject.h
+++ b/tests/auto/cmake/test_qtmainwin_library/myobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt b/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt
new file mode 100644
index 0000000000..16563141f4
--- /dev/null
+++ b/tests/auto/cmake/test_resource_without_obj_lib/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_resource_without_obj_lib)
+
+if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
+endif()
+
+find_package(Qt6 REQUIRED
+ COMPONENTS Core Test
+ HINTS ${Qt6Tests_PREFIX_PATH}
+)
+
+qt6_add_library(helper_lib STATIC helper_lib.cpp)
+qt6_add_resources(helper_lib "helper_res" FILES resource.txt PREFIX "/")
+
+# Link to Core, to ensure both the helper_lib and the main executable
+# inherit the QT_NAMESPACE if it is set, otherwise we get undefined
+# linker errors due to the mismatch in symbol names.
+target_link_libraries(helper_lib PRIVATE Qt6::Core)
+
+set(CMAKE_AUTOMOC ON)
+
+qt6_add_executable(test_resource_without_obj_lib main.cpp)
+target_link_libraries(test_resource_without_obj_lib PRIVATE Qt6::Core Qt6::Test)
+
+# Link against the library file and not the target, so that we can confirm
+# the ability to manually initialize the resource via Q_INIT_RESOURCE.
+target_link_libraries(test_resource_without_obj_lib PRIVATE $<TARGET_FILE:helper_lib>)
+
diff --git a/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp b/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp
new file mode 100644
index 0000000000..cd21e6c476
--- /dev/null
+++ b/tests/auto/cmake/test_resource_without_obj_lib/helper_lib.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+void nothing() {}
diff --git a/tests/auto/cmake/test_resource_without_obj_lib/main.cpp b/tests/auto/cmake/test_resource_without_obj_lib/main.cpp
new file mode 100644
index 0000000000..bffbf81b87
--- /dev/null
+++ b/tests/auto/cmake/test_resource_without_obj_lib/main.cpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/qtresource.h>
+#include <QtTest/QtTest>
+
+class TestManualResourceInit : public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void resourceExistsAfterManualInit();
+};
+
+void TestManualResourceInit::initTestCase()
+{
+ // Manually initialize the resource like we used to do it in qt5 + qmake times.
+ Q_INIT_RESOURCE(helper_res);
+}
+
+void TestManualResourceInit::resourceExistsAfterManualInit()
+{
+ QVERIFY(QFile::exists(":/resource.txt"));
+}
+
+QTEST_MAIN(TestManualResourceInit)
+#include "main.moc"
+
diff --git a/tests/auto/cmake/test_resource_without_obj_lib/resource.txt b/tests/auto/cmake/test_resource_without_obj_lib/resource.txt
new file mode 100644
index 0000000000..7804a324a4
--- /dev/null
+++ b/tests/auto/cmake/test_resource_without_obj_lib/resource.txt
@@ -0,0 +1 @@
+Test resource
diff --git a/tests/auto/cmake/test_standalone_test/CMakeLists.txt b/tests/auto/cmake/test_standalone_test/CMakeLists.txt
new file mode 100644
index 0000000000..169d824c88
--- /dev/null
+++ b/tests/auto/cmake/test_standalone_test/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(tststandalone_test LANGUAGES CXX)
+find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+
+qt_internal_add_test(tst_standalone_test
+ GUI
+ SOURCES
+ tst_standalone_test.cpp
+ LIBRARIES
+ Qt::Gui
+)
diff --git a/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp b/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp
new file mode 100644
index 0000000000..fa533602ec
--- /dev/null
+++ b/tests/auto/cmake/test_standalone_test/tst_standalone_test.cpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+#include <QWindow>
+
+class tst_standalone_test : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testLaunched()
+ {
+ QWindow w;
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ }
+};
+
+QTEST_MAIN(tst_standalone_test)
+
+#include "tst_standalone_test.moc"
diff --git a/tests/auto/cmake/test_static_resources/.cmake.conf b/tests/auto/cmake/test_static_resources/.cmake.conf
new file mode 100644
index 0000000000..10bc1fd407
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/.cmake.conf
@@ -0,0 +1 @@
+set(QT_REPO_MODULE_VERSION "6.8.0")
diff --git a/tests/auto/cmake/test_static_resources/CMakeLists.txt b/tests/auto/cmake/test_static_resources/CMakeLists.txt
new file mode 100644
index 0000000000..e3cab9cf4a
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+include(.cmake.conf)
+
+project(TestStaticResources
+ DESCRIPTION "Test of the static resources"
+ HOMEPAGE_URL "https://qt.io/"
+ LANGUAGES CXX C
+ VERSION "${QT_REPO_MODULE_VERSION}"
+)
+
+find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
+qt_internal_project_setup()
+
+qt_build_repo_begin()
+
+enable_testing()
+add_subdirectory(mock_static_resources1)
+add_subdirectory(test_init_resources_static_plugin)
+add_subdirectory(test_static_resources_propagation)
+
+qt_build_repo_post_process()
+qt_build_repo_end()
diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt
new file mode 100644
index 0000000000..f866f0af46
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_module(MockStaticResources1
+ NO_UNITY_BUILD
+ STATIC
+ PLUGIN_TYPES mockstaticresources
+ SOURCES
+ dummy.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ PUBLIC_LIBRARIES
+ Qt::Core
+)
+
+qt_internal_add_resource(MockStaticResources1 "teststaticmodule1"
+ PREFIX
+ "/teststaticmodule1"
+ FILES
+ "testfile1.txt"
+)
diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake b/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake
new file mode 100644
index 0000000000..46da2db2b8
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/configure.cmake
@@ -0,0 +1,2 @@
+# This is needed so that MODULE_PLUGIN_TYPES property is set on the exported target.
+# Fun times.
diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp
new file mode 100644
index 0000000000..b6c23a82eb
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+void dummy() { }
diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt b/tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/testfile1.txt
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt
new file mode 100644
index 0000000000..dec5588a6d
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC
+ NO_UNITY_BUILD
+ OUTPUT_NAME
+ testinitresourcesstaticplugin
+ PLUGIN_TYPE mockstaticresources
+ SOURCES
+ pluginmain.cpp
+ SKIP_INSTALL
+ LIBRARIES
+ Qt::Core
+)
+
+qt_internal_add_resource(TestInitResourcesStaticPlugin "teststaticplugin1"
+ PREFIX
+ "/teststaticplugin1"
+ FILES
+ "testfile1.txt"
+)
+
+qt_internal_add_resource(TestInitResourcesStaticPlugin "teststaticplugin2"
+ PREFIX
+ "/teststaticplugin2"
+ FILES
+ "testfile2.txt"
+)
+
+qt_internal_add_test(test_init_resources_static_plugin
+ SOURCES
+ test_init_resources_static_plugin.cpp
+ LIBRARIES
+ Qt::Core
+ TestInitResourcesStaticPlugin
+)
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp
new file mode 100644
index 0000000000..a95e54ee4f
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+class TestStaticPlugin : public QObject
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "TestStaticPlugin" URI "qt.teststaticplugin")
+public:
+ TestStaticPlugin() = default;
+ Q_INVOKABLE bool checkResources()
+ {
+ return QFile::exists(":/teststaticplugin1/testfile1.txt")
+ && QFile::exists(":/teststaticplugin2/testfile2.txt");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "pluginmain.moc"
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp
new file mode 100644
index 0000000000..2067b8c920
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QtCore/qfile.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qpluginloader.h>
+#include <QtPlugin>
+
+Q_IMPORT_PLUGIN(TestStaticPlugin)
+
+class TestInitResourcesStaticPlugin : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceFilesExist();
+};
+
+void TestInitResourcesStaticPlugin::resourceFilesExist()
+{
+ bool result = false;
+ for (QObject *obj : QPluginLoader::staticInstances()) {
+ if (obj->metaObject()->className() == QLatin1String("TestStaticPlugin")) {
+ QMetaObject::invokeMethod(obj, "checkResources", Qt::DirectConnection,
+ Q_RETURN_ARG(bool, result));
+ }
+ break;
+ }
+ QVERIFY(result);
+}
+
+QTEST_MAIN(TestInitResourcesStaticPlugin)
+#include "test_init_resources_static_plugin.moc"
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile1.txt
diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/testfile2.txt
diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt
new file mode 100644
index 0000000000..b802323cfc
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt
@@ -0,0 +1,180 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+# TODO: Revisit which of these tests makes sense to keep now that we depend on CMake 3.21 to
+# properly place object libraries object files on the link line.
+# See QTBUG-95601
+#
+#
+#
+#
+# Add a dummy library that links the static "Qt" module containing resources
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" CONTENT "void dummy() { }")
+add_library(dummy STATIC "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
+set_target_properties(dummy PROPERTIES UNITY_BUILD OFF)
+target_link_libraries(dummy PRIVATE MockStaticResources1)
+
+# Add the executable using qt_add_executable that needs to initialize the propagated resources.
+# Finalize it implicitly(since CMake version 3.19).
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+ qt_add_executable(test_static_resources_propagation main.cpp)
+ set_target_properties(test_static_resources_propagation PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+ )
+ target_link_libraries(test_static_resources_propagation
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+ )
+ add_test(NAME test_static_resources_propagation
+ COMMAND test_static_resources_propagation
+ )
+endif()
+
+
+# Add the executable using qt_add_executable that needs to initialize the propagated resources.
+# Finalize it explicitly.
+qt_add_executable(test_static_resources_propagation_manual_finalize main.cpp MANUAL_FINALIZATION)
+set_target_properties(test_static_resources_propagation_manual_finalize PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+)
+target_link_libraries(test_static_resources_propagation_manual_finalize
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+)
+qt_finalize_target(test_static_resources_propagation_manual_finalize)
+add_test(NAME test_static_resources_propagation_manual_finalize
+ COMMAND test_static_resources_propagation_manual_finalize
+)
+
+# Add the executable using add_executable that needs to initialize the propagated resources.
+# Finalize it explicitly.
+add_executable(test_static_resources_propagation_non_qt main.cpp)
+set_target_properties(test_static_resources_propagation_non_qt PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+)
+target_link_libraries(test_static_resources_propagation_non_qt
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+)
+qt_finalize_target(test_static_resources_propagation_non_qt)
+add_test(NAME test_static_resources_propagation_non_qt
+ COMMAND test_static_resources_propagation_non_qt
+)
+
+get_target_property(link_order_matters
+ ${QT_CMAKE_EXPORT_NAMESPACE}::Platform
+ _qt_link_order_matters
+)
+
+if(NOT link_order_matters)
+ # Add the executable using add_executable, expecting resources to be linked regardless of order.
+ add_executable(test_static_resources_propagation_non_ld main.cpp)
+ set_target_properties(test_static_resources_propagation_non_ld PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+ )
+ target_link_libraries(test_static_resources_propagation_non_ld
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+ )
+ add_test(NAME test_static_resources_propagation_non_ld
+ COMMAND test_static_resources_propagation_non_ld
+ )
+
+# FIXME: qt6_enable_object_libraries_finalizer_mode is not available anymore. See QTBUG-95601
+#
+# if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
+# qt_add_executable(test_static_resources_propagation_not_finalize main.cpp)
+# qt6_enable_object_libraries_finalizer_mode(
+# test_static_resources_propagation_not_finalize FALSE
+# )
+# set_target_properties(test_static_resources_propagation_not_finalize PROPERTIES
+# AUTOMOC TRUE
+# )
+# target_link_libraries(test_static_resources_propagation_not_finalize
+# PRIVATE
+# dummy
+# Qt::Core
+# Qt::Test
+# )
+# add_test(NAME test_static_resources_propagation_not_finalize
+# COMMAND test_static_resources_propagation_not_finalize
+# )
+# endif()
+endif()
+
+# Add the executable using add_executable, expecting resources are propagated using
+# target_link_options approach. The test is not applicable for qt_add_executable call since
+# we use the CMP0099 policy NEW unless the actual version of CMake is lower than 3.17, that means
+# target_link_options will always be preferable to finalizers.
+if(POLICY CMP0099)
+ cmake_policy(PUSH)
+
+ cmake_policy(SET CMP0099 OLD)
+ # When CMP0099 is set to OLD target_link_options doesn't propagate the linker options when
+ # linking static libraries with a PRIVATE visibility but we finalize it explicitly. This
+ # is a pure finalizer use case for platforms where link order matters.
+ add_executable(test_static_resources_propagation_cmp0099_old_finalize main.cpp)
+ set_target_properties(test_static_resources_propagation_cmp0099_old_finalize PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+ )
+ target_link_libraries(test_static_resources_propagation_cmp0099_old_finalize
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+ )
+ qt_finalize_target(test_static_resources_propagation_cmp0099_old_finalize)
+ add_test(NAME test_static_resources_propagation_cmp0099_old_finalize
+ COMMAND test_static_resources_propagation_cmp0099_old_finalize
+ )
+
+ # When CMP0099 is set to NEW target_link_options propagates the linker options when linking
+ # static libraries with a PRIVATE visibility. This is a pure target_link_options use case for
+ # platforms where link order matters.
+ cmake_policy(SET CMP0099 NEW)
+ add_executable(test_static_resources_propagation_cmp0099_new main.cpp)
+ set_target_properties(test_static_resources_propagation_cmp0099_new PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+ )
+ target_link_libraries(test_static_resources_propagation_cmp0099_new
+ PRIVATE
+ dummy
+ Qt::Core
+ Qt::Test
+ )
+ add_test(NAME test_static_resources_propagation_cmp0099_new
+ COMMAND test_static_resources_propagation_cmp0099_new
+ )
+
+ # Check if linking libraries using genex propagates resource objects when CMP0099 is enabled
+ add_executable(test_static_resources_propagation_cmp0099_new_genex main.cpp)
+ set_target_properties(test_static_resources_propagation_cmp0099_new_genex PROPERTIES
+ AUTOMOC TRUE
+ UNITY_BUILD OFF
+ )
+ target_link_libraries(test_static_resources_propagation_cmp0099_new_genex
+ PRIVATE
+ $<1:dummy>
+ Qt::Core
+ Qt::Test
+ )
+ add_test(NAME test_static_resources_propagation_cmp0099_new_genex
+ COMMAND test_static_resources_propagation_cmp0099_new_genex
+ )
+
+ cmake_policy(POP)
+endif()
diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp
new file mode 100644
index 0000000000..c5d5312eb8
--- /dev/null
+++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp
@@ -0,0 +1,23 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtTest/QtTest>
+#include <QtCore/qfile.h>
+#include <QtCore/qobject.h>
+#include <QtPlugin>
+
+class TestStaticResourcePropagation : public QObject
+{
+ Q_OBJECT
+private slots:
+ void resourceFilesExist();
+};
+
+void TestStaticResourcePropagation::resourceFilesExist()
+{
+ bool result = QFile::exists(":/teststaticmodule1/testfile1.txt");
+ QVERIFY(result);
+}
+
+QTEST_MAIN(TestStaticResourcePropagation)
+#include "main.moc"
diff --git a/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt
index e6f2ad1cae..3c83af7e0a 100644
--- a/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_definitions/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_testlib_definitions)
diff --git a/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt
index cc68be18b8..872f291eeb 100644
--- a/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_definitions/core_only/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
project(core_only)
diff --git a/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt
index 528ec7dc4e..737de2c95f 100644
--- a/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_definitions/gui/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
project(gui)
diff --git a/tests/auto/cmake/test_testlib_definitions/main.cpp b/tests/auto/cmake/test_testlib_definitions/main.cpp
index dce6db51ed..9452adb817 100644
--- a/tests/auto/cmake/test_testlib_definitions/main.cpp
+++ b/tests/auto/cmake/test_testlib_definitions/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
#include <QTest>
diff --git a/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt b/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt
index 0dbf9139e6..5aae260fa8 100644
--- a/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_definitions/widgets/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
project(widgets)
diff --git a/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt b/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt
index ef552cacc6..2515f61d05 100644
--- a/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_no_link_gui/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(no_link_gui)
diff --git a/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt b/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt
index ed9a8707da..89965032b2 100644
--- a/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt
+++ b/tests/auto/cmake/test_testlib_no_link_widgets/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(no_link_widgets)
diff --git a/tests/auto/cmake/test_umbrella_config/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/CMakeLists.txt
index cfe809c084..624374b8b2 100644
--- a/tests/auto/cmake/test_umbrella_config/CMakeLists.txt
+++ b/tests/auto/cmake/test_umbrella_config/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_umbrella_config)
diff --git a/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt
index 999aaccdd2..7341c9ab19 100644
--- a/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt
+++ b/tests/auto/cmake/test_umbrella_config/components_found/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
# The module finds its dependencies
find_package(Qt6 6.0.0
diff --git a/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt b/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt
index aa56559c8f..dee3edb3fd 100644
--- a/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt
+++ b/tests/auto/cmake/test_umbrella_config/components_not_found/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
# The module finds its dependencies
find_package(Qt6
diff --git a/tests/auto/cmake/test_versionless_targets/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
index c670f5b26d..1afcaa6a93 100644
--- a/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
+++ b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
@@ -1,23 +1,103 @@
-cmake_minimum_required(VERSION 3.14)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
project(versionless_targets)
-set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
+function(check_versionless_targets)
+ set(known_interface_properties
+ QT_MAJOR_VERSION
+ AUTOMOC_MACRO_NAMES
+ AUTOUIC_OPTIONS
+ COMPILE_DEFINITIONS
+ COMPILE_FEATURES
+ COMPILE_OPTIONS
+ CXX_MODULE_SETS
+ HEADER_SETS
+ HEADER_SETS_TO_VERIFY
+ INCLUDE_DIRECTORIES
+ LINK_DEPENDS
+ LINK_DIRECTORIES
+ LINK_LIBRARIES
+ LINK_LIBRARIES_DIRECT
+ LINK_LIBRARIES_DIRECT_EXCLUDE
+ LINK_OPTIONS
+ POSITION_INDEPENDENT_CODE
+ PRECOMPILE_HEADERS
+ SOURCES
+ SYSTEM_INCLUDE_DIRECTORIES
+ )
+
+ set(known_qt_exported_properties
+ MODULE_PLUGIN_TYPES
+ QT_DISABLED_PRIVATE_FEATURES
+ QT_DISABLED_PUBLIC_FEATURES
+ QT_ENABLED_PRIVATE_FEATURES
+ QT_ENABLED_PUBLIC_FEATURES
+ QT_QMAKE_PRIVATE_CONFIG
+ QT_QMAKE_PUBLIC_CONFIG
+ QT_QMAKE_PUBLIC_QT_CONFIG
+ _qt_config_module_name
+ _qt_is_public_module
+ _qt_module_has_headers
+ _qt_module_has_private_headers
+ _qt_module_has_public_headers
+ _qt_module_has_qpa_headers
+ _qt_module_has_rhi_headers
+ _qt_module_include_name
+ _qt_module_interface_name
+ _qt_package_name
+ _qt_package_version
+ _qt_private_module_target_name
+ )
-find_package(Qt6Core REQUIRED)
+ foreach(prop ${known_interface_properties})
+ set(versionless_prop "")
+ set(versioned_prop "")
+ get_target_property(versionless_prop Qt::Core INTERFACE_${prop})
+ get_target_property(versioned_prop Qt6::Core INTERFACE_${prop})
+ if(NOT versionless_prop AND NOT versioned_prop)
+ continue()
+ endif()
-if (NOT TARGET Qt6::Core)
- message(SEND_ERROR "Qt6::Core target not defined!")
-endif()
+ if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
+ message(SEND_ERROR "INTERFACE_${prop} doesn't match versionless ${versionless_prop}"
+ " versioned ${versioned_prop}")
+ endif()
+ endforeach()
-if (TARGET Qt::Core)
- message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
-endif()
+ foreach(prop ${known_qt_exported_properties})
+ set(versionless_prop "")
+ set(versioned_prop "")
+ get_target_property(versionless_prop Qt::Core ${prop})
+ get_target_property(versioned_prop Qt6::Core ${prop})
+ if(NOT versionless_prop AND NOT versioned_prop)
+ continue()
+ endif()
-set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
+ if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
+ message(SEND_ERROR "${prop} doesn't match versionless ${versionless_prop}"
+ " versioned ${versioned_prop}")
+ endif()
+ endforeach()
-find_package(Qt6Core REQUIRED)
+ foreach(conf "" _RELEASE _DEBUG _RELWITHDEBINFO _MINSIZEREL)
+ set(versionless_prop "")
+ set(versioned_prop "")
+ get_target_property(versionless_prop Qt::Core IMPORTED_LOCATION${conf})
+ get_target_property(versioned_prop Qt6::Core IMPORTED_LOCATION${conf})
+ if(NOT versionless_prop AND NOT versioned_prop)
+ continue()
+ endif()
+ if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
+ message(SEND_ERROR "IMPORTED_LOCATION${conf} doesn't match versionless ${versionless_prop}"
+ " versioned ${versioned_prop}")
+ endif()
+ endforeach()
+endfunction()
-if (NOT TARGET Qt::Core)
- message(SEND_ERROR "Qt::Core target not defined!")
-endif()
+add_subdirectory(default)
+add_subdirectory(force_off)
+add_subdirectory(force_on)
+add_subdirectory(force_old)
diff --git a/tests/auto/cmake/test_versionless_targets/default/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/default/CMakeLists.txt
new file mode 100644
index 0000000000..a8757607cf
--- /dev/null
+++ b/tests/auto/cmake/test_versionless_targets/default/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+message("Test default creating of versionless targets")
+find_package(Qt6Core REQUIRED)
+
+if(NOT TARGET Qt6::Core)
+ message(SEND_ERROR "Qt6::Core target not defined!")
+endif()
+
+if(NOT TARGET Qt::Core)
+ message(SEND_ERROR "Qt::Core target not defined!")
+endif()
+
+check_versionless_targets()
diff --git a/tests/auto/cmake/test_versionless_targets/force_off/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/force_off/CMakeLists.txt
new file mode 100644
index 0000000000..247b1b8c27
--- /dev/null
+++ b/tests/auto/cmake/test_versionless_targets/force_off/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+message("Test disabled versionless targets")
+
+set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
+
+find_package(Qt6Core REQUIRED)
+
+if(NOT TARGET Qt6::Core)
+ message(SEND_ERROR "Qt6::Core target not defined!")
+endif()
+
+if(TARGET Qt::Core)
+ message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
+endif()
diff --git a/tests/auto/cmake/test_versionless_targets/force_old/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/force_old/CMakeLists.txt
new file mode 100644
index 0000000000..9e83fec7b3
--- /dev/null
+++ b/tests/auto/cmake/test_versionless_targets/force_old/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+message("Test force old versionless targets")
+
+set(QT_USE_OLD_VERSION_LESS_TARGETS ON)
+
+find_package(Qt6Core REQUIRED)
+
+if(NOT TARGET Qt6::Core)
+ message(SEND_ERROR "Qt6::Core target not defined!")
+endif()
+
+if(NOT TARGET Qt::Core)
+ message(SEND_ERROR "Qt::Core target not defined!")
+endif()
+
+check_versionless_targets()
+
diff --git a/tests/auto/cmake/test_versionless_targets/force_on/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/force_on/CMakeLists.txt
new file mode 100644
index 0000000000..b3d7596143
--- /dev/null
+++ b/tests/auto/cmake/test_versionless_targets/force_on/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+message("Test enabled versionless targets")
+
+set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
+
+find_package(Qt6Core REQUIRED)
+
+if(NOT TARGET Qt6::Core)
+ message(SEND_ERROR "Qt6::Core target not defined!")
+endif()
+
+if(NOT TARGET Qt::Core)
+ message(SEND_ERROR "Qt::Core target not defined!")
+endif()
+
+check_versionless_targets()
diff --git a/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt b/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt
new file mode 100644
index 0000000000..9457278e12
--- /dev/null
+++ b/tests/auto/cmake/test_widgets_app_deployment/CMakeLists.txt
@@ -0,0 +1,74 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(deployment_api)
+enable_testing()
+
+find_package(Qt6 COMPONENTS REQUIRED Widgets Test)
+
+qt6_standard_project_setup()
+
+function(create_test_executable target)
+ cmake_parse_arguments(arg "" "" "" ${ARGN})
+
+ if(CMAKE_VERSION VERSION_LESS "3.19")
+ qt_add_executable(${target} MANUAL_FINALIZATION main.cpp)
+ else()
+ qt_add_executable(${target} main.cpp)
+ endif()
+
+ set_target_properties(${target} PROPERTIES
+ # We explicitly don't set WIN32_EXECUTABLE to ensure we see errors from stderr when
+ # something fails and not having to use DebugView.
+
+ MACOSX_BUNDLE TRUE
+ )
+ target_link_libraries(${target} PRIVATE Qt::Widgets Qt::Test)
+
+ install(TARGETS ${target}
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+
+ qt_generate_deploy_app_script(
+ TARGET ${target}
+ OUTPUT_SCRIPT deploy_script
+ # Don't fail at configure time on unsupported platforms
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ )
+ install(SCRIPT ${deploy_script})
+
+ if(CMAKE_VERSION VERSION_LESS "3.19")
+ qt_finalize_target(${target})
+ endif()
+
+ if(APPLE AND NOT IOS)
+ set(installed_app_location "${CMAKE_INSTALL_PREFIX}/${target}.app/Contents/MacOS/${target}")
+ elseif(WIN32)
+ set(installed_app_location "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${target}.exe")
+ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT CMAKE_CROSSCOMPILING)
+ set(installed_app_location "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${target}")
+ endif()
+
+ # There's no nice way to get the location of an installed binary, so we need to construct
+ # the binary install path by hand, somewhat similar to how it's done in
+ # the implementation of qt_deploy_runtime_dependencies.
+ # On unsupported deployment platforms, either the install_ test will fail not finding
+ # the location of the app (because we do not set a installed_app_location value)
+ # or the run_deployed_ test will fail because we didn't deploy the runtime dependencies.
+ # When support for additional platforms is added, these locations will have to be augmented.
+ add_test(install_${target} "${CMAKE_COMMAND}" --install .)
+ set_tests_properties(install_${target} PROPERTIES FIXTURES_SETUP deploy_step)
+ add_test(NAME run_deployed_${target}
+ COMMAND "${installed_app_location}"
+ # Make sure that we don't use the default working directory which is
+ # CMAKE_CURRENT_BINARY_DIR because on Windows the loader might pick up dlls
+ # from the working directory instead of the installed app dir, if the dll is
+ # missing in the app dir.
+ WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}")
+ set_tests_properties(run_deployed_${target} PROPERTIES FIXTURES_REQUIRED deploy_step)
+endfunction()
+
+create_test_executable(App)
+
diff --git a/tests/auto/cmake/test_widgets_app_deployment/main.cpp b/tests/auto/cmake/test_widgets_app_deployment/main.cpp
new file mode 100644
index 0000000000..939cd72380
--- /dev/null
+++ b/tests/auto/cmake/test_widgets_app_deployment/main.cpp
@@ -0,0 +1,22 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+#include <QtTest>
+#include <QMainWindow>
+
+class test_widgets_app_deployment : public QObject
+{
+ Q_OBJECT
+private slots:
+ void canRun();
+};
+
+void test_widgets_app_deployment::canRun()
+{
+ QMainWindow mw;
+ mw.show();
+ QVERIFY(QTest::qWaitForWindowActive(&mw));
+}
+
+QTEST_MAIN(test_widgets_app_deployment)
+
+#include "main.moc"
diff --git a/tests/auto/cmake/test_wrap_cpp_and_resources/CMakeLists.txt b/tests/auto/cmake/test_wrap_cpp_and_resources/CMakeLists.txt
index 3e026db737..da413168ff 100644
--- a/tests/auto/cmake/test_wrap_cpp_and_resources/CMakeLists.txt
+++ b/tests/auto/cmake/test_wrap_cpp_and_resources/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_wrap_cpp_and_resources)
diff --git a/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp b/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp
index c4889d0882..3adda87348 100644
--- a/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp
+++ b/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "myobject.h"
diff --git a/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h b/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h
index c5b32c680d..87d7bfa3df 100644
--- a/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h
+++ b/tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/tests/auto/cmake/test_wrap_cpp_moc/CMakeLists.txt b/tests/auto/cmake/test_wrap_cpp_moc/CMakeLists.txt
new file mode 100644
index 0000000000..c00a9d83c5
--- /dev/null
+++ b/tests/auto/cmake/test_wrap_cpp_moc/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(test_wrap_cpp_and_resources)
+
+find_package(Qt6Core REQUIRED)
+
+add_executable(example main.cpp)
+
+qt_wrap_cpp(moc_files main.cpp TARGET example)
+
+# expect the generated moc files to be empty when a source file is passed
+if (NOT moc_files STREQUAL "")
+ message(FATAL_ERROR "test_qt_wrap_cpp_moc: moc_files should be empty")
+endif()
+
+target_link_libraries(example PRIVATE Qt::Core)
diff --git a/tests/auto/cmake/test_wrap_cpp_moc/main.cpp b/tests/auto/cmake/test_wrap_cpp_moc/main.cpp
new file mode 100644
index 0000000000..28ebfe0536
--- /dev/null
+++ b/tests/auto/cmake/test_wrap_cpp_moc/main.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QObject>
+
+class MyObject2 : public QObject {
+ Q_OBJECT
+public:
+ MyObject2() = default;
+};
+
+#include "main.moc"
+
+int main()
+{
+ return 0;
+}
diff --git a/tests/auto/cmake/test_wrap_cpp_options/CMakeLists.txt b/tests/auto/cmake/test_wrap_cpp_options/CMakeLists.txt
index e6e972e852..80f4992da7 100644
--- a/tests/auto/cmake/test_wrap_cpp_options/CMakeLists.txt
+++ b/tests/auto/cmake/test_wrap_cpp_options/CMakeLists.txt
@@ -1,5 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
+
+cmake_minimum_required(VERSION 3.16)
project(test_wrap_cpp_options)
diff --git a/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp b/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
index 600281e1db..14e00e789a 100644
--- a/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
+++ b/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "myobject.h"
diff --git a/tests/auto/cmake/test_wrap_cpp_options/myobject.h b/tests/auto/cmake/test_wrap_cpp_options/myobject.h
index c5b32c680d..87d7bfa3df 100644
--- a/tests/auto/cmake/test_wrap_cpp_options/myobject.h
+++ b/tests/auto/cmake/test_wrap_cpp_options/myobject.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MYOBJECT_H
#define MYOBJECT_H
diff --git a/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt b/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt
new file mode 100644
index 0000000000..bc1a6339db
--- /dev/null
+++ b/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qaddpreroutine Test:
+#####################################################################
+cmake_minimum_required(VERSION 3.16)
+
+if(DEFINED CMAKE_Core_MODULE_MAJOR_VERSION)
+ set(project_version "${CMAKE_Core_MODULE_MAJOR_VERSION}.\
+${CMAKE_Core_MODULE_MINOR_VERSION}.${CMAKE_Core_MODULE_PATCH_VERSION}"
+ )
+else()
+ set(project_version "6.0.0")
+endif()
+
+project(tst_qaddpreroutine
+ LANGUAGES CXX
+ VERSION "${project_version}"
+)
+
+find_package(Qt6 COMPONENTS Core BuildInternals CONFIG REQUIRED)
+qt_prepare_standalone_project()
+
+find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED)
+
+qt_internal_add_plugin(QTBUG_90341ThemePlugin
+ NO_UNITY_BUILD
+ OUTPUT_NAME QTBUG_90341
+ OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
+ CLASS_NAME ThemePlugin
+ PLUGIN_TYPE platformthemes
+ DEFAULT_IF TRUE
+ SOURCES
+ plugin.cpp
+ SKIP_INSTALL
+ LIBRARIES
+ Qt::Core
+ Qt::Gui
+ Qt::GuiPrivate
+)
+
+qt_internal_add_test(tst_qaddpreroutine
+ SOURCES
+ tst_qaddpreroutine.cpp
+ LIBRARIES
+ Qt::Gui
+)
+
+
+target_compile_definitions(tst_qaddpreroutine
+ PRIVATE QT_QPA_PLATFORM_PLUGIN_PATH=\"${CMAKE_BINARY_DIR}\")
diff --git a/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp b/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp
new file mode 100644
index 0000000000..1647d8d3a8
--- /dev/null
+++ b/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp
@@ -0,0 +1,45 @@
+// Copyright (C) 2021 zccrs <zccrs@live.com>, JiDe Zhang <zhangjide@uniontech.com>.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <qpa/qplatformthemeplugin.h>
+#include <qpa/qplatformtheme.h>
+#include <QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+// The "test_function_call_count" property will be used in the "tst_qaddpreroutine.cpp".
+// This plugin is part of the test case. It is used to call qAddPreRoutine through
+// Q_COREAPP_STARTUP_FUNCTION on the plugin loading. Please treat it as a whole
+// with "tst_qaddpreroutine.cpp".
+static void test()
+{
+ Q_ASSERT(qApp != nullptr);
+ int call_count = qApp->property("test_function_call_count").toInt();
+ // Record the number of times A is called, in this example, it should be called only once.
+ qApp->setProperty("test_function_call_count", call_count + 1);
+}
+Q_COREAPP_STARTUP_FUNCTION(test)
+
+class ThemePlugin : public QPlatformThemePlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "plugin.json")
+
+public:
+ QPlatformTheme *create(const QString &key, const QStringList &params) override;
+};
+
+QPlatformTheme *ThemePlugin::create(const QString &key, const QStringList &params)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(params);
+
+ // Used to verify whether this plugin was successfully loaded.
+ qputenv("QTBUG_90341_ThemePlugin", "1");
+
+ return new QPlatformTheme();
+}
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
diff --git a/tests/auto/cmake/tst_qaddpreroutine/plugin.json b/tests/auto/cmake/tst_qaddpreroutine/plugin.json
new file mode 100644
index 0000000000..5e360bbae2
--- /dev/null
+++ b/tests/auto/cmake/tst_qaddpreroutine/plugin.json
@@ -0,0 +1,3 @@
+{
+ "Keys": ["QTBUG_90341"]
+}
diff --git a/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp b/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp
new file mode 100644
index 0000000000..21394648c0
--- /dev/null
+++ b/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2021 zccrs <zccrs@live.com>, JiDe Zhang <zhangjide@uniontech.com>.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+#include <QGuiApplication>
+
+class tst_qAddPreRoutine : public QObject
+{
+ Q_OBJECT
+
+public:
+ static void initMain()
+ {
+ // The purpose of this use case is indeed to test "qAddPreRoutine", but
+ // as you can see, there is nowhere to call "qAddPreRoutine". Please see
+ // the following two lines of code, which set the "QT_QPA_PLATFORM_PLUGIN_PATH"
+ // and "QT_QPA_PLATFORMTHEME" environment variables that a new platform
+ // theme plugin will be loaded, and the Q_COREAPP_STARTUP_FUNCTION macro
+ // is used in this plugin, which will cause "qAddPreRoutine" to be called
+ // indirectly in the Q*Application class when load the platform theme plugin.
+ // See the "plugin.cpp" file.
+#ifndef Q_OS_ANDROID // The plug-in is in the apk package, no need to specify its directory
+ qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", QT_QPA_PLATFORM_PLUGIN_PATH);
+#endif
+ qputenv("QT_QPA_PLATFORMTHEME", "QTBUG_90341");
+ }
+
+private slots:
+ void tst_QTBUG_90341()
+ {
+#ifdef Q_OS_ANDROID
+ QSKIP("Android can't load the platform theme plugin this test needs, see QTBUG-92893");
+#endif
+ QVERIFY2(qEnvironmentVariableIsSet("QTBUG_90341_ThemePlugin"),
+ "The \"QTBUG_90341\" theme plugin not loaded.");
+ // This "test_function_call_count" property is assigned in the "QTBUG_90341" plugin.
+ // See the "plugin.cpp" file.
+ QCOMPARE(qApp->property("test_function_call_count").toInt(), 1);
+ }
+};
+
+QTEST_MAIN(tst_qAddPreRoutine)
+
+#include "tst_qaddpreroutine.moc"