summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake')
-rw-r--r--tests/auto/cmake/CMakeLists.txt54
-rw-r--r--tests/auto/cmake/mockplugins/.cmake.conf2
-rw-r--r--tests/auto/cmake/mockplugins/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/fake.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins2/fake.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/fake.cpp2
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h2
-rw-r--r--tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp2
-rw-r--r--tests/auto/cmake/test(needsquoting)dirname/mywidget.h2
-rw-r--r--tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp2
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.cpp2
-rw-r--r--tests/auto/cmake/test_QTBUG-63422/mywidget.h2
-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/main.cpp2
-rw-r--r--tests/auto/cmake/test_add_big_resource/myobject.cpp2
-rw-r--r--tests/auto/cmake/test_add_big_resource/myobject.h2
-rw-r--r--tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp2
-rw-r--r--tests/auto/cmake/test_add_resource_options/myobject.cpp2
-rw-r--r--tests/auto/cmake/test_add_resource_options/myobject.h2
-rw-r--r--tests/auto/cmake/test_add_resource_prefix/main.cpp2
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp2
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h2
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp2
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h2
-rw-r--r--tests/auto/cmake/test_add_resources_big_resources/main.cpp2
-rw-r--r--tests/auto/cmake/test_add_resources_binary_generated/main.cpp2
-rw-r--r--tests/auto/cmake/test_add_resources_delayed_file/main.cpp2
-rw-r--r--tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp2
-rw-r--r--tests/auto/cmake/test_build_simple_widget_app/main.cpp2
-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/main.cpp2
-rw-r--r--tests/auto/cmake/test_config_expressions/CMakeLists.txt134
-rw-r--r--tests/auto/cmake/test_dbus_module/mydbusobject.cpp2
-rw-r--r--tests/auto/cmake/test_dbus_module/mydbusobject.h2
-rw-r--r--tests/auto/cmake/test_dependent_modules/mywidget.cpp2
-rw-r--r--tests/auto/cmake/test_dependent_modules/mywidget.h2
-rw-r--r--tests/auto/cmake/test_egl_lib/main.cpp2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/.cmake.conf2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.h2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/use_api.cpp2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.cpp2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/module_api.h2
-rw-r--r--tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/use_api.cpp2
-rw-r--r--tests/auto/cmake/test_import_plugins/main.cpp2
-rw-r--r--tests/auto/cmake/test_interface/main.cpp2
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.cpp2
-rw-r--r--tests/auto/cmake/test_interface/mainwindow.h2
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/main.cpp2
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/somelib.cpp2
-rw-r--r--tests/auto/cmake/test_interface_link_libraries/somelib.h2
-rw-r--r--tests/auto/cmake/test_json_plugin_includes/plugin.cpp2
-rw-r--r--tests/auto/cmake/test_json_plugin_includes/plugin.h2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/CMakeLists.txt29
-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.h2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp2
-rw-r--r--tests/auto/cmake/test_moc_macro_target/mywrapobject.h2
-rw-r--r--tests/auto/cmake/test_multiple_find_package/main.cpp2
-rw-r--r--tests/auto/cmake/test_opengl_lib/main.cpp2
-rw-r--r--tests/auto/cmake/test_platform_defs_include/main.cpp2
-rw-r--r--tests/auto/cmake/test_plugin_shared_static_flavor.cmake2
-rw-r--r--tests/auto/cmake/test_private_includes/main.cpp2
-rw-r--r--tests/auto/cmake/test_private_targets/main.cpp2
-rw-r--r--tests/auto/cmake/test_qt_add_ui_1/CMakeLists.txt62
-rw-r--r--tests/auto/cmake/test_qt_add_ui_10/CMakeLists.txt62
-rw-r--r--tests/auto/cmake/test_qt_add_ui_2/CMakeLists.txt60
-rw-r--r--tests/auto/cmake/test_qt_add_ui_3/CMakeLists.txt199
-rw-r--r--tests/auto/cmake/test_qt_add_ui_4/CMakeLists.txt65
-rw-r--r--tests/auto/cmake/test_qt_add_ui_5/CMakeLists.txt164
-rw-r--r--tests/auto/cmake/test_qt_add_ui_6/CMakeLists.txt64
-rw-r--r--tests/auto/cmake/test_qt_add_ui_7/CMakeLists.txt62
-rw-r--r--tests/auto/cmake/test_qt_add_ui_8/CMakeLists.txt67
-rw-r--r--tests/auto/cmake/test_qt_add_ui_9/CMakeLists.txt66
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/CMakeLists.txt7
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/RunCMake.cmake157
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/main.cpp14
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/mainwindow.h26
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/main.cpp14
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.cpp28
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.h25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/mainwindow.ui33
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/widget1.ui52
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.cpp25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.h28
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui52
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.cpp25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.h29
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/sub1/sub2/sub3/sub4/CMakeLists.txt39
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/widget1.ui45
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/CMakeLists.txt33
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/main.cpp14
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.cpp28
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.h25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.ui33
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.cpp25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.h28
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.ui52
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.cpp25
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.h29
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.ui45
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/functions.cmake223
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/main.cpp4
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt65
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp17
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui45
-rw-r--r--tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui45
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/MetaType.cpp2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/main.cpp2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmpty.h2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeEmptyWithComment.h2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECT.h2
-rw-r--r--tests/auto/cmake/test_qt_extract_metatypes/test_qt_extract_metatypes_project/testdata/MetaTypeQ_OBJECTandQ_PROPERTY.h2
-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/myobject.cpp2
-rw-r--r--tests/auto/cmake/test_qtmainwin_library/myobject.h2
-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.conf2
-rw-r--r--tests/auto/cmake/test_static_resources/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp2
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/pluginmain.cpp2
-rw-r--r--tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/test_init_resources_static_plugin.cpp2
-rw-r--r--tests/auto/cmake/test_static_resources/test_static_resources_propagation/main.cpp2
-rw-r--r--tests/auto/cmake/test_testlib_definitions/main.cpp2
-rw-r--r--tests/auto/cmake/test_versionless_targets/CMakeLists.txt103
-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/main.cpp2
-rw-r--r--tests/auto/cmake/test_wrap_cpp_and_resources/myobject.cpp2
-rw-r--r--tests/auto/cmake/test_wrap_cpp_and_resources/myobject.h2
-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/myobject.cpp2
-rw-r--r--tests/auto/cmake/test_wrap_cpp_options/myobject.h2
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/plugin.cpp2
-rw-r--r--tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp2
159 files changed, 3093 insertions, 100 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index d64e180870..b159de7c9c 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -116,7 +116,7 @@ include("${_Qt6CTestMacros}")
# 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)
+ 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)
@@ -197,6 +197,7 @@ endif()
_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)
@@ -222,6 +223,7 @@ _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)
@@ -337,6 +339,12 @@ if(is_qt_build_platform)
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)
@@ -388,3 +396,47 @@ if(WIN32 OR (APPLE AND NOT IOS) OR is_desktop_linux)
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)
+
+# check if the os is opensuse. If it is, we need to skip tests due to CI problems
+set(is_opensuse FALSE)
+if(UNIX)
+ if(EXISTS "/etc/os-release")
+ file(STRINGS "/etc/os-release" os_release_content)
+ foreach(line IN LISTS os_release_content)
+ if(line MATCHES "openSUSE" OR line MATCHES "opensuse")
+ set(is_opensuse TRUE)
+ break()
+ endif()
+ endforeach()
+ endif()
+endif()
+
+if(NOT QNX AND NOT WASM AND NOT (WIN32 AND QT_BUILD_MINIMAL_STATIC_TESTS)
+ AND NOT is_opensuse)
+ # Since our CI machines are slow, ctest --build-and-test buffers the output
+ # of the configure step of a test, and the fact that we run all the test
+ # logic in the configure step, we need to divide the tests into smaller
+ # chunks to avoid CI stdout timeout errors.
+ # See https://gitlab.kitware.com/cmake/cmake/-/issues/25790
+ _qt_internal_test_expect_pass(test_qt_add_ui_common)
+ _qt_internal_test_expect_pass(test_qt_add_ui_1)
+ _qt_internal_test_expect_pass(test_qt_add_ui_2)
+ _qt_internal_test_expect_pass(test_qt_add_ui_3)
+ _qt_internal_test_expect_pass(test_qt_add_ui_4)
+ _qt_internal_test_expect_pass(test_qt_add_ui_5)
+ _qt_internal_test_expect_pass(test_qt_add_ui_6)
+ _qt_internal_test_expect_pass(test_qt_add_ui_7)
+ _qt_internal_test_expect_pass(test_qt_add_ui_8)
+ _qt_internal_test_expect_pass(test_qt_add_ui_9)
+ _qt_internal_test_expect_pass(test_qt_add_ui_10)
+endif()
+
diff --git a/tests/auto/cmake/mockplugins/.cmake.conf b/tests/auto/cmake/mockplugins/.cmake.conf
index 146dd2bd5a..10bc1fd407 100644
--- a/tests/auto/cmake/mockplugins/.cmake.conf
+++ b/tests/auto/cmake/mockplugins/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.6.0")
+set(QT_REPO_MODULE_VERSION "6.8.0")
diff --git a/tests/auto/cmake/mockplugins/CMakeLists.txt b/tests/auto/cmake/mockplugins/CMakeLists.txt
index 0711631dec..1bde9aedb1 100644
--- a/tests/auto/cmake/mockplugins/CMakeLists.txt
+++ b/tests/auto/cmake/mockplugins/CMakeLists.txt
@@ -12,6 +12,8 @@ project(QtMockPlugins
)
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()
@@ -27,4 +29,5 @@ 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/qmock1plugin.h b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
index 192b8c0591..324d0c38f4 100644
--- a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
+++ b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/qmock2plugin.h b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
index 4d3765f28c..a1217ff4d6 100644
--- a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
+++ b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/qmock3plugin.h b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
index 8143c06c43..3e152784e0 100644
--- a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
+++ b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/qmock4plugin.h b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
index 3aad9a6cae..1895367575 100644
--- a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
+++ b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/qmock5plugin.h b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
index 5f2c9eeeb9..4b6c95fb23 100644
--- a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
+++ b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/qmock6plugin.h b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
index e2a3eb10c5..5278d67960 100644
--- a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
+++ b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// 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/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
index f71e2748a2..6cdf6a09ce 100644
--- a/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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 9caf6b973a..d4dcea5c20 100644
--- a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
+++ b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCKPLUGIN_H
#define QMOCKPLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
index 2ad5f6144a..9256ef181f 100644
--- a/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QtGlobal>
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
index 5a3c187143..9ca82b9ef7 100644
--- a/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
+++ b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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 cc92d16a76..599c3ecbb4 100644
--- a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
+++ b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QMOCKAUXPLUGIN_H
#define QMOCKAUXPLUGIN_H
diff --git a/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp b/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
index c0e3870c91..da7f51d286 100644
--- a/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
+++ b/tests/auto/cmake/test(needsquoting)dirname/mywidget.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 8b8e2ee350..4517670b56 100644
--- a/tests/auto/cmake/test(needsquoting)dirname/mywidget.h
+++ b/tests/auto/cmake/test(needsquoting)dirname/mywidget.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/tests/main.cpp b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
index 52732df425..7938bbb863 100644
--- a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
+++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 Stephen Kelly <steveire@gmail,com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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/mywidget.cpp b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
index 0657edf2b2..adbfcd35e8 100644
--- a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 203a3876ed..f975ae2fa3 100644
--- a/tests/auto/cmake/test_QTBUG-63422/mywidget.h
+++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/main.cpp b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp
index 7911bf74e7..ae34d13ff1 100644
--- a/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp
+++ b/tests/auto/cmake/test_QT_TESTCASE_BUILDDIR/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QCoreApplication>
#include <QtTest/QTest>
diff --git a/tests/auto/cmake/test_add_big_resource/myobject.cpp b/tests/auto/cmake/test_add_big_resource/myobject.cpp
index 12434f4689..34c2ccc6bf 100644
--- a/tests/auto/cmake/test_add_big_resource/myobject.cpp
+++ b/tests/auto/cmake/test_add_big_resource/myobject.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 917ae9fd24..87d7bfa3df 100644
--- a/tests/auto/cmake/test_add_big_resource/myobject.h
+++ b/tests/auto/cmake/test_add_big_resource/myobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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_binary_resources_delayed_file/main.cpp b/tests/auto/cmake/test_add_binary_resources_delayed_file/main.cpp
index b8b6ec7717..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,5 +1,5 @@
// Copyright (C) 2015 André Klitzing <aklitzing@gmail.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QResource>
diff --git a/tests/auto/cmake/test_add_resource_options/myobject.cpp b/tests/auto/cmake/test_add_resource_options/myobject.cpp
index 2a90499e6a..14e00e789a 100644
--- a/tests/auto/cmake/test_add_resource_options/myobject.cpp
+++ b/tests/auto/cmake/test_add_resource_options/myobject.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 917ae9fd24..87d7bfa3df 100644
--- a/tests/auto/cmake/test_add_resource_options/myobject.h
+++ b/tests/auto/cmake/test_add_resource_options/myobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/main.cpp b/tests/auto/cmake/test_add_resource_prefix/main.cpp
index cad519423f..1a8b37715b 100644
--- a/tests/auto/cmake/test_add_resource_prefix/main.cpp
+++ b/tests/auto/cmake/test_add_resource_prefix/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QtTest>
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
index 00817d496d..a8f2be6955 100644
--- a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "leaf_lib.h"
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
index 614ebd1abc..efa03e8a5e 100644
--- a/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
+++ b/tests/auto/cmake/test_add_resources_big_resources/intermediate_lib.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
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
index 0dc07784e9..8363ceec0a 100644
--- a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/qfile.h>
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
index 9a6c631c1d..71195a7c74 100644
--- a/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
+++ b/tests/auto/cmake/test_add_resources_big_resources/leaf_lib.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
diff --git a/tests/auto/cmake/test_add_resources_big_resources/main.cpp b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
index 5df2b0e5a7..8ff0c4f54c 100644
--- a/tests/auto/cmake/test_add_resources_big_resources/main.cpp
+++ b/tests/auto/cmake/test_add_resources_big_resources/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "intermediate_lib.h"
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 906232ca19..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,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QFile>
#include <QResource>
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 9f722faff4..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/main.cpp b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp
index a0c5ae2de5..304c7b20dc 100644
--- a/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp
+++ b/tests/auto/cmake/test_android_multi_abi_forward_vars/main.cpp
@@ -1,4 +1,4 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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/main.cpp b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
index 734c72a263..b4502fa05a 100644
--- a/tests/auto/cmake/test_build_simple_widget_app/main.cpp
+++ b/tests/auto/cmake/test_build_simple_widget_app/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QApplication>
#include <QWidget>
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/main.cpp b/tests/auto/cmake/test_concurrent_module/main.cpp
index afecfadf27..9412c60638 100644
--- a/tests/auto/cmake/test_concurrent_module/main.cpp
+++ b/tests/auto/cmake/test_concurrent_module/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/mydbusobject.cpp b/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
index 356b09d2fa..c9420812b4 100644
--- a/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
+++ b/tests/auto/cmake/test_dbus_module/mydbusobject.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 3559ecd4dc..8a95c99f04 100644
--- a/tests/auto/cmake/test_dbus_module/mydbusobject.h
+++ b/tests/auto/cmake/test_dbus_module/mydbusobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/mywidget.cpp b/tests/auto/cmake/test_dependent_modules/mywidget.cpp
index c0e3870c91..da7f51d286 100644
--- a/tests/auto/cmake/test_dependent_modules/mywidget.cpp
+++ b/tests/auto/cmake/test_dependent_modules/mywidget.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 8b8e2ee350..4517670b56 100644
--- a/tests/auto/cmake/test_dependent_modules/mywidget.h
+++ b/tests/auto/cmake/test_dependent_modules/mywidget.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 39d4d8b14c..b5faa46dd3 100644
--- a/tests/auto/cmake/test_egl_lib/main.cpp
+++ b/tests/auto/cmake/test_egl_lib/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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
index 146dd2bd5a..10bc1fd407 100644
--- a/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
+++ b/tests/auto/cmake/test_generating_cpp_exports/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.6.0")
+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
index 3de368ba1a..564d23ca05 100644
--- a/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
+++ b/tests/auto/cmake/test_generating_cpp_exports/CMakeLists.txt
@@ -13,10 +13,12 @@ project(TestGeneratingCppExports
)
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/module_api.cpp b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/module_api.cpp
index 53eab3ef6f..e77895e719 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "module_api.h"
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
index ef1288078a..6c8112c617 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MODULE_API_H
#define 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
index 5bce4e524e..f84931300f 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "module_api.h"
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
index 53eab3ef6f..e77895e719 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "module_api.h"
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
index 81b15704ff..62c1b31ac4 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MODULE_API_H
#define 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
index 5bce4e524e..f84931300f 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "module_api.h"
diff --git a/tests/auto/cmake/test_import_plugins/main.cpp b/tests/auto/cmake/test_import_plugins/main.cpp
index 8de124c41d..69293f3abd 100644
--- a/tests/auto/cmake/test_import_plugins/main.cpp
+++ b/tests/auto/cmake/test_import_plugins/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 Kitware, Inc.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QList>
#include <QPluginLoader>
diff --git a/tests/auto/cmake/test_interface/main.cpp b/tests/auto/cmake/test_interface/main.cpp
index a8f072aff3..56b442a4ce 100644
--- a/tests/auto/cmake/test_interface/main.cpp
+++ b/tests/auto/cmake/test_interface/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 878265f9c3..2fec6400f6 100644
--- a/tests/auto/cmake/test_interface/mainwindow.cpp
+++ b/tests/auto/cmake/test_interface/mainwindow.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 1f938d2bd9..345c4f69e9 100644
--- a/tests/auto/cmake/test_interface/mainwindow.h
+++ b/tests/auto/cmake/test_interface/mainwindow.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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_link_libraries/main.cpp b/tests/auto/cmake/test_interface_link_libraries/main.cpp
index 75e6f22db0..7d4ca031db 100644
--- a/tests/auto/cmake/test_interface_link_libraries/main.cpp
+++ b/tests/auto/cmake/test_interface_link_libraries/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 106f534bb2..de51a8e60f 100644
--- a/tests/auto/cmake/test_interface_link_libraries/somelib.cpp
+++ b/tests/auto/cmake/test_interface_link_libraries/somelib.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 828937c13c..d2f0cfd554 100644
--- a/tests/auto/cmake/test_interface_link_libraries/somelib.h
+++ b/tests/auto/cmake/test_interface_link_libraries/somelib.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/plugin.cpp b/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
index 8979c56b77..5554fe737a 100644
--- a/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
+++ b/tests/auto/cmake/test_json_plugin_includes/plugin.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 36e5eb55b2..7e3e9b4569 100644
--- a/tests/auto/cmake/test_json_plugin_includes/plugin.h
+++ b/tests/auto/cmake/test_json_plugin_includes/plugin.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 1af937bc10..f9ca294bd2 100644
--- a/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
+++ b/tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
@@ -14,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)
@@ -24,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 60ff102037..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 5ffb740e9d..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 2f403d95c6..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 7398cce9ee..28030a5832 100644
--- a/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
+++ b/tests/auto/cmake/test_moc_macro_target/mywrapobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/main.cpp b/tests/auto/cmake/test_multiple_find_package/main.cpp
index 7db90ad9c5..820a550917 100644
--- a/tests/auto/cmake/test_multiple_find_package/main.cpp
+++ b/tests/auto/cmake/test_multiple_find_package/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QString>
diff --git a/tests/auto/cmake/test_opengl_lib/main.cpp b/tests/auto/cmake/test_opengl_lib/main.cpp
index 86cdd29a48..b29d11f667 100644
--- a/tests/auto/cmake/test_opengl_lib/main.cpp
+++ b/tests/auto/cmake/test_opengl_lib/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qglobal.h>
diff --git a/tests/auto/cmake/test_platform_defs_include/main.cpp b/tests/auto/cmake/test_platform_defs_include/main.cpp
index 5e61b3f393..30d2e2065a 100644
--- a/tests/auto/cmake/test_platform_defs_include/main.cpp
+++ b/tests/auto/cmake/test_platform_defs_include/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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
index f692abdb45..ffe5fb5447 100644
--- a/tests/auto/cmake/test_plugin_shared_static_flavor.cmake
+++ b/tests/auto/cmake/test_plugin_shared_static_flavor.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# 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
diff --git a/tests/auto/cmake/test_private_includes/main.cpp b/tests/auto/cmake/test_private_includes/main.cpp
index fee93f978d..6dc90fbae0 100644
--- a/tests/auto/cmake/test_private_includes/main.cpp
+++ b/tests/auto/cmake/test_private_includes/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <QScreen>
diff --git a/tests/auto/cmake/test_private_targets/main.cpp b/tests/auto/cmake/test_private_targets/main.cpp
index 509d27d23b..4566fd6ce6 100644
--- a/tests/auto/cmake/test_private_targets/main.cpp
+++ b/tests/auto/cmake/test_private_targets/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 Stephen Kelly <steveire@gmail.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
diff --git a/tests/auto/cmake/test_qt_add_ui_1/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_1/CMakeLists.txt
new file mode 100644
index 0000000000..882abecc0b
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_1/CMakeLists.txt
@@ -0,0 +1,62 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ if(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: ui_mainwindow.h is included as
+ # "sub1/sub2/sub3/sub4/../../../../src/ui_files/ui_mainwindow.h".
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: No build folder leakage and generation of the
+ # sub1/sub2/sub3/sub4 folder in ${hash_folder}/include
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder( "example" "${test_ui_file}" hash_folder)
+ string(CONCAT test_build_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/UicBuildLeak_incPathGen"
+ "${config_path}-build")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_additional_args "-DMAINWINDOW_UI_PATH=sub1/sub2/"
+ "sub3/sub4/../../../../src/ui_files/")
+ string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/src/ui_files/ui_mainwindow.h")
+ string(CONCAT test_folder_to_check "${test_build_dir}/.qt/"
+ "${hash_folder}/${config_arg}/sub1/sub2/sub3/sub4")
+ incremental_build_test(
+ TEST_NAME UicBuildLeak_incPathGen
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ ADDITIONAL_ARGS "${test_additional_args}"
+ FILE_TO_TOUCH "${test_ui_file}"
+ FILE_TO_CHECK "${test_file_to_check}"
+ FOLDER_TO_CHECK "${test_folder_to_check}"
+ )
+ endforeach()
+endforeach()
+
diff --git a/tests/auto/cmake/test_qt_add_ui_10/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_10/CMakeLists.txt
new file mode 100644
index 0000000000..6b223fb281
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_10/CMakeLists.txt
@@ -0,0 +1,62 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: mainwindow.ui file is touched after the first build. The
+ # ui_mainwindow.h should be generated without the ${config_arg} folder.
+ # Expect 1: Successful build without the double build issue.
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "qt_add_ui_simple_no_config${config_path}-build")
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder(
+ "example"
+ "${test_ui_file}"
+ hash_folder)
+ incremental_build_test(
+ TEST_NAME qt6_add_ui_simple_no_config
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ CONFIG "${config_arg}"
+ ADDITIONAL_ARGS "-DUI_NO_CONFIG_OPTIONS=ON"
+ FILE_TO_TOUCH "${test_file_to_touch}"
+ FILE_TO_CHECK
+ "${test_build_dir}/.qt/${hash_folder}/ui_mainwindow.h"
+ )
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_2/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_2/CMakeLists.txt
new file mode 100644
index 0000000000..dceb0c7a2e
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_2/CMakeLists.txt
@@ -0,0 +1,60 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: mainwindow.ui file is touched after the first build.
+ # Expect 1: Successful build without the double build issue.
+ set(test_build_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/qt_add_ui_simple${config_path}-build")
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder(
+ "example"
+ "${test_ui_file}"
+ hash_folder)
+ incremental_build_test(
+ TEST_NAME qt6_add_ui_simple
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ CONFIG "${config_arg}"
+ FILE_TO_TOUCH "${test_file_to_touch}"
+ FILE_TO_CHECK
+ "${test_build_dir}/.qt/${hash_folder}/${config_arg}/ui_mainwindow.h"
+ )
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_3/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_3/CMakeLists.txt
new file mode 100644
index 0000000000..81a9a38431
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_3/CMakeLists.txt
@@ -0,0 +1,199 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ if(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: Check whether api sets warning against AUTOUIC activation.
+ # Expect 1: Printing of the error message and failure of the build.
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_warning_test${config_path}-build")
+ run_cmake_configure(SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ CLEAN_FIRST
+ ADDITIONAL_ARGS "-DCMAKE_AUTOUIC=ON"
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+ if(NOT cmake_result EQUAL 0)
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error: "
+ "${cmake_error}\nFAIL: \"uic_warning_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}-"
+ "build failed to configure")
+ else()
+ message(STATUS "PASS: \"uic_warning_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}-"
+ "build was configured successfully")
+ endif()
+
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_warning_test${config_path}-build")
+ run_cmake_build(
+ BUILD_DIR "${test_build_dir}"
+ VERBOSE ON
+ CONFIG "${config_arg}"
+ OUTPUT_VARIABLE cmake_build_output
+ RESULT_VARIABLE cmake_build_result)
+ if(NOT cmake_build_result EQUAL 0)
+ message(STATUS "PASS: \"uic_warning_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}"
+ "-build failed to build")
+ else()
+ message(FATAL_ERROR "FAIL: \"uic_warning_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}-"
+ "build was built successfully")
+ endif()
+ expect_string_contains("${cmake_build_output}" "has \"AUTOUIC\" enabled"
+ SUCCESS_MESSAGE "\"uic_warning_test\" test in \
+${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}-build \
+has \"has AUTOUIC enabled\""
+ FAILURE_MESSAGE "\"uic_warning_test\" test in \
+${CMAKE_CURRENT_BINARY_DIR}/uic_warning_test${config_path}-build \
+does not have \"has AUTOUIC enabled\"")
+
+
+ if("${generator}" MATCHES "Ninja")
+ # Test case: If INCLUDE_PREFIX is changed without changing the
+ # corresponding include path in the source file and Ninja generator
+ # is used, this casues the double build issue.
+ # Note: Only happens in Ninja generator.
+ # Expect 1: Failure of the build in the first build.
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_double_build_test${config_path}-build")
+ run_cmake_configure(SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ CLEAN_FIRST
+ ADDITIONAL_ARGS "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3/"
+ "-DDO_NOT_GENERATE_FILE=ON"
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+
+ if(NOT cmake_result EQUAL 0)
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error"
+ ": ${cmake_error}\nFAIL: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build failed to configure")
+ else()
+ message(STATUS "PASS: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build was configured successfully")
+ endif()
+
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_double_build_test${config_path}-build")
+ run_cmake_build(
+ BUILD_DIR "${test_build_dir}"
+ VERBOSE ON
+ CONFIG "${config_arg}"
+ OUTPUT_VARIABLE cmake_build_output
+ RESULT_VARIABLE cmake_build_result)
+
+ if(NOT cmake_build_result EQUAL 0)
+ message(FATAL_ERROR "cmake_build_output: ${cmake_build_output}"
+ "FAIL: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build failed to build in the first build")
+ else()
+ message(STATUS "PASS: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build was built successfully in the first "
+ "build")
+ endif()
+
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_double_build_test${config_path}-build")
+ run_cmake_configure(SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ # We change the INCLUDE_PREFIX here.
+ ADDITIONAL_ARGS "-DMAINWINDOW_UI_PATH=sub1/sub2/sub/"
+ "-DDO_NOT_GENERATE_FILE=ON"
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+
+ if(NOT cmake_result EQUAL 0)
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error"
+ ":${cmake_error}\nFAIL: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build failed to configure in the second "
+ "build")
+ else()
+ message(STATUS "PASS: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build was configured successfully in the "
+ "second build")
+ endif()
+
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_double_build_test${config_path}-build")
+ run_cmake_build(
+ BUILD_DIR "${test_build_dir}"
+ VERBOSE ON
+ CONFIG "${config_arg}"
+ OUTPUT_VARIABLE cmake_build_output
+ ERROR_VARIABLE cmake_build_error
+ RESULT_VARIABLE cmake_build_result)
+
+ if(NOT cmake_build_result EQUAL 0)
+ message(STATUS "PASS: \"uic_double_build_test\" test in"
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build failed to build in the first build "
+ "after changing INCLUDE_PREFIX")
+ else()
+ message(FATAL_ERROR "cmake_build_output: ${cmake_build_output}"
+ "\ncmake_build_error: ${cmake_build_error}\n"
+ "FAIL: \"uic_double_build_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test"
+ "${config_path}-build was built successfully in the first "
+ "build after changing INCLUDE_PREFIX")
+ endif()
+
+ set(expected_fail_string "No such file or directory|file not found")
+ expect_string_contains(${cmake_build_output}
+ "${expected_fail_string}"
+ SUCCESS_MESSAGE "\"uic_double_build_test\" test in \
+${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test${config_path}\
+-build has \"ui_mainwindow.h: No such file or directory\" in \
+the first build after changing INCLUDE_PREFIX"
+ FAILURE_MESSAGE "\"uic_double_build_test\" test in \
+${CMAKE_CURRENT_BINARY_DIR}/uic_double_build_test${config_path}\
+-build does not have \"ui_mainwindow.h: No such file or \
+directory\" in the first build after changing INCLUDE_PREFIX")
+
+ endif()
+ endforeach()
+endforeach()
+
diff --git a/tests/auto/cmake/test_qt_add_ui_4/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_4/CMakeLists.txt
new file mode 100644
index 0000000000..51c74352d6
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_4/CMakeLists.txt
@@ -0,0 +1,65 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: widget1.ui file is touched after the first build.
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: Only touched files to be built
+ set(test_build_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/UicIncrementalBuild${config_path}-build")
+ string(CONCAT ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/UicIncrementalBuild/src/widget1.ui")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/UicIncrementalBuild")
+
+ generate_hash_folder(
+ "example"
+ "${ui_file}"
+ hash_folder)
+ string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/src/ui_widget1.h")
+ incremental_build_test(
+ TEST_NAME UicIncrementalBuild
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ FILE_TO_TOUCH "${ui_file}"
+ FILE_TO_CHECK
+ "${test_file_to_check}"
+ FOLDER_TO_CHECK
+ "${test_build_dir}/.qt/${hash_folder}/${config_arg}/src"
+ CHECK_UNWANTED_BUILDS
+ )
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_5/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_5/CMakeLists.txt
new file mode 100644
index 0000000000..7b29bcf52b
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_5/CMakeLists.txt
@@ -0,0 +1,164 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ if(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+
+ if("${generator}" MATCHES "Ninja")
+ # Test case: Add a new ui file to CMakeLists.txt after the first
+ # build.
+ # Expect 1: Expect ${target}_autogen/prefix_info.cmake to be
+ # generated as expected.
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_prefix_info_cmake_test${config_path}-build")
+ run_cmake_configure(SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ CLEAN_FIRST
+ ADDITIONAL_ARGS "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3/"
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+
+ if(NOT cmake_result EQUAL 0)
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error"
+ ":${cmake_error}\nFAIL: \"uic_prefix_info_cmake_test\" test"
+ " in ${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build failed to configure")
+ else()
+ message(STATUS "PASS: \"uic_prefix_info_cmake_test\" test in"
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build was configured successfully")
+ endif()
+
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder("example" "${test_ui_file}"
+ hash_folder_mainwindow)
+ string(CONCAT expected_prefix_info_cmake_content
+ "include_guard()\nset(${hash_folder_mainwindow}_prefix \""
+ "sub1/sub2/sub3\")")
+ # read the content of the prefix_info.cmake file
+ string(CONCAT "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_prefix_info_cmake_test${config_path}-build")
+ file(READ
+ "${test_build_dir}/example_autogen/prefix_info.cmake"
+ prefix_info_cmake_content)
+
+ if("${prefix_info_cmake_content}" STREQUAL
+ "${expected_prefix_info_cmake_content}")
+ message(STATUS "PASS: \"uic_prefix_info_cmake_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build has the expected content in "
+ "prefix_info.cmake")
+ else()
+ message(FATAL_ERROR "FAIL: \"uic_prefix_info_cmake_test\" test "
+ "in ${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build does not have the expected content in"
+ " prefix_info.cmake")
+ endif()
+
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_prefix_info_cmake_test${config_path}-build")
+ run_cmake_build(
+ BUILD_DIR "${test_build_dir}"
+ VERBOSE ON
+ CONFIG "${config_arg}"
+ OUTPUT_VARIABLE cmake_build_output
+ ERROR_VARIABLE cmake_build_error
+ RESULT_VARIABLE cmake_build_result)
+
+ if(NOT cmake_build_result EQUAL 0)
+ message(FATAL_ERROR "cmake_build_output: ${cmake_build_output}"
+ "\ncmake_build_error: ${cmake_build_error}\n"
+ "FAIL: \"uic_prefix_info_cmake_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build failed to build in the first build")
+ else()
+ message(STATUS "PASS: \"uic_prefix_info_cmake_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build was built successfully in the first "
+ "build")
+ endif()
+
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_prefix_info_cmake_test${config_path}-build")
+ run_cmake_configure(SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ GENERATOR "${generator}"
+ ADDITIONAL_ARGS "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3/"
+ "-DNEW_UI_PATH=sub5/sub6/sub7/ " "-DADD_NEW_UI=ON"
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+
+ if(NOT cmake_result EQUAL 0)
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error"
+ ": ${cmake_error}\nFAIL: \"uic_prefix_info_cmake_test\" "
+ "test in ${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_"
+ "test ${config_path}-build failed to configure in the"
+ "second build")
+ else()
+ message(STATUS "PASS: \"uic_prefix_info_cmake_test\" test in"
+ " ${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build was configured successfully in the "
+ "second build")
+ endif()
+
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/subdir/mainwindow.ui")
+ generate_hash_folder("example" "${test_ui_file}"
+ hash_folder_subdir_mainwindow)
+ set(expected_prefix_info_cmake_content
+ "include_guard()\nset(${hash_folder_subdir_mainwindow}_prefix \
+\"sub5/sub6/sub7\")")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "uic_prefix_info_cmake_test${config_path}-build")
+ file(READ
+ "${test_build_dir}/example_autogen/prefix_info.cmake"
+ prefix_info_cmake_content)
+
+ if("${prefix_info_cmake_content}" STREQUAL
+ "${expected_prefix_info_cmake_content}")
+ message(STATUS "PASS: \"uic_prefix_info_cmake_test\" test in "
+ "${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build has the expected content in "
+ "prefix_info.cmake")
+ else()
+ message(FATAL_ERROR "FAIL: \"uic_prefix_info_cmake_test\" test "
+ "in ${CMAKE_CURRENT_BINARY_DIR}/uic_prefix_info_cmake_test"
+ "${config_path}-build does not have the expected content "
+ "in prefix_info.cmake")
+ endif()
+ endif()
+ endforeach()
+endforeach()
+
diff --git a/tests/auto/cmake/test_qt_add_ui_6/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_6/CMakeLists.txt
new file mode 100644
index 0000000000..2d57c6067d
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_6/CMakeLists.txt
@@ -0,0 +1,64 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: ui_mainwindow.h is included as
+ # "../../../../src/ui_files/ui_mainwindow.h".
+ # Test case: mainwindow1.ui file is touched after the first build.
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: No build folder leakage and generation of the "_/_/_/_/"
+ # folder in ${hash_folder}/include.
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../test_qt_add_ui_"
+ "common/uic_test/mainwindow.ui")
+ generate_hash_folder("example" "${test_ui_file}" hash_folder)
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/UicBuildLeak_"
+ "subFolderGen${config_path}-build")
+ string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/src/ui_files/ui_mainwindow.h")
+ incremental_build_test(
+ TEST_NAME UicBuildLeak_subFolderGen
+ SOURCE_DIR
+ "${CMAKE_CURRENT_SOURCE_DIR}/../test_qt_add_ui_common/uic_test"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ ADDITIONAL_ARGS "-DMAINWINDOW_UI_PATH=../../../../src/ui_files/"
+ FILE_TO_TOUCH "${test_file_to_touch}"
+ FILE_TO_CHECK "${test_file_to_check}"
+ FOLDER_TO_CHECK
+ "${test_build_dir}/.qt/${hash_folder}/${config_arg}/_/_/_/_"
+ )
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_7/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_7/CMakeLists.txt
new file mode 100644
index 0000000000..8278f13a72
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_7/CMakeLists.txt
@@ -0,0 +1,62 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case 1: There are two widget1.ui files in different folders.
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: Only touched files to be built.
+ string(CONCAT ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/sub1/sub2/sub3/"
+ "sub4")
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "UicIncBuild_sameFileDiffFolder${config_path}-build")
+ string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui")
+ generate_hash_folder(
+ "example"
+ "${ui_file}"
+ hash_folder)
+ incremental_build_test(
+ TEST_NAME UicIncBuild_sameFileDiffFolder
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ FILE_TO_TOUCH "${test_file_to_touch}"
+ CHECK_UNWANTED_BUILDS
+ )
+
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_8/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_8/CMakeLists.txt
new file mode 100644
index 0000000000..f8d0763d35
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_8/CMakeLists.txt
@@ -0,0 +1,67 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ # A CI test fails with the below condition. So, we are running the test
+ # only for the Debug configuration.
+ if ("${generator}" MATCHES "Xcode" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(configs "Debug")
+ elseif(multi_config_out)
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: ui_mainwindow.h is included as
+ # "sub1/sub2/sub3/../../../../../../../../../../../../../ui_mainwindow.h".
+ # Test case: mainwindow1.ui file is touched after the first build.
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: No build folder leakage and generation of the
+ # "_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3" folder in ${hash_folder}/include.
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder("example" "${test_ui_file}" hash_folder)
+ string(CONCAT test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/"
+ "UicBuildLeak_subFolderGen_complex${config_path}-build")
+ string(CONCAT test_additional_args "-DMAINWINDOW_UI_PATH=sub1/sub2/sub3"
+ "/../../../../../../../../../../../../../")
+ string(CONCAT test_file_to_touch "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/ui_mainwindow.h")
+ string(CONCAT test_folder_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/_/_/_/_/_/_/_/_/_/_/sub1/sub2/sub3")
+ incremental_build_test(
+ TEST_NAME UicBuildLeak_subFolderGen_complex
+ SOURCE_DIR
+ "${CMAKE_CURRENT_SOURCE_DIR}/../test_qt_add_ui_common/uic_test"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ ADDITIONAL_ARGS "${test_additional_args}"
+ FILE_TO_TOUCH "${test_file_to_touch}"
+ FILE_TO_CHECK "${test_file_to_check}"
+ FOLDER_TO_CHECK "${test_folder_to_check}"
+ )
+ endforeach()
+endforeach()
diff --git a/tests/auto/cmake/test_qt_add_ui_9/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_9/CMakeLists.txt
new file mode 100644
index 0000000000..9e28ddc927
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_9/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)
+
+include(../test_qt_add_ui_common/RunCMake.cmake)
+include(../test_qt_add_ui_common/functions.cmake)
+
+get_generators(generators)
+
+foreach(generator IN ITEMS ${generators})
+ message(STATUS "Running tests for generator: ${generator}")
+ is_multi_config(${generator} multi_config_out)
+ if(multi_config_out)
+ # Since our CI machines are slow, ctest --build-and-test buffers the
+ # output of the configure step of a test, and the fact that we run all
+ # the test logic in the configure step, we need to exclude Release
+ # to avoid CI stdout timeout errors.
+ # See https://gitlab.kitware.com/cmake/cmake/-/issues/25790
+ set(configs "Debug" "Release")
+ else()
+ set(configs "single_config")
+ endif()
+
+ foreach(config IN ITEMS ${configs})
+ if("${config}" STREQUAL "single_config")
+ set(config_path "")
+ set(config_arg "")
+ else()
+ set(config_path "_${config}")
+ set(config_arg "${config}")
+ endif()
+
+ # Test case: ui_mainwindow.h is included as
+ # "sub2/sub3/../../../src/ui_files/ui_mainwindow.h".
+ # Expect 1: Successful build without the double build issue.
+ # Expect 2: No build folder leakage and generation of
+ # _/sub2/sub3 in ${hash_folder}/include.
+ # Note: This test case is a mix of previous two test cases.
+ string(CONCAT test_ui_file "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test/mainwindow.ui")
+ generate_hash_folder("example" "${test_ui_file}" hash_folder)
+ set(test_build_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/UicBuildLeak_mix${config_path}-build")
+ string(CONCAT test_additional_args "-DMAINWINDOW_UI_PATH=sub2/sub3/"
+ "../../../src/ui_files/")
+ string(CONCAT test_file_to_check "${test_build_dir}/.qt/${hash_folder}/"
+ "${config_arg}/src/ui_files/ui_mainwindow.h")
+ string(CONCAT test_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/../"
+ "test_qt_add_ui_common/uic_test")
+ incremental_build_test(
+ TEST_NAME UicBuildLeak_mix
+ SOURCE_DIR "${test_source_dir}"
+ BUILD_DIR "${test_build_dir}"
+ CONFIG "${config_arg}"
+ GENERATOR "${generator}"
+ ADDITIONAL_ARGS "${test_additional_args}"
+ FILE_TO_TOUCH "${test_ui_file}"
+ FILE_TO_CHECK "${test_file_to_check}"
+ FOLDER_TO_CHECK
+ "${test_build_dir}/.qt/${hash_folder}/${config_arg}/_/sub2/sub3"
+ )
+ endforeach()
+endforeach()
+
diff --git a/tests/auto/cmake/test_qt_add_ui_common/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_common/CMakeLists.txt
new file mode 100644
index 0000000000..628dc9373a
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(test)
+
+add_executable(test main.cpp)
diff --git a/tests/auto/cmake/test_qt_add_ui_common/RunCMake.cmake b/tests/auto/cmake/test_qt_add_ui_common/RunCMake.cmake
new file mode 100644
index 0000000000..6b39fe3398
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/RunCMake.cmake
@@ -0,0 +1,157 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(run_cmake_configure)
+ set(options CLEAN_FIRST)
+ set(oneValueArgs SOURCE_DIR BUILD_DIR RESULT_VARIABLE OUTPUT_VARIABLE
+ ERROR_VARIABLE GENERATOR)
+ set(multiValueArgs ADDITIONAL_ARGS)
+
+ cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}"
+ ${ARGN})
+
+ if(NOT arg_SOURCE_DIR)
+ message(FATAL_ERROR "SOURCE_DIR not specified")
+ endif()
+
+ if(NOT arg_BUILD_DIR)
+ message(FATAL_ERROR "BUILD_DIR not specified")
+ endif()
+
+ is_multi_config(arg_GENERATOR multi_config_out)
+ if (NOT ${multi_config_out})
+ set(run_arg_config_arg -Darg_TYPE=Debug)
+ endif()
+
+ set(test_project_source_dir ${arg_SOURCE_DIR})
+ set(test_project_build_dir ${arg_BUILD_DIR})
+
+ # 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)
+
+ if(arg_CLEAN_FIRST)
+ file(REMOVE_RECURSE "${test_project_build_dir}")
+ endif()
+ file(MAKE_DIRECTORY "${test_project_build_dir}")
+
+ execute_process(COMMAND
+ "${CMAKE_COMMAND}"
+ -S "${test_project_source_dir}"
+ -B "${test_project_build_dir}"
+ -G "${arg_GENERATOR}"
+ "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+ ${run_arg_config_arg}
+ ${arg_ADDITIONAL_ARGS}
+ RESULT_VARIABLE cmake_result
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+ ECHO_OUTPUT_VARIABLE
+ ECHO_ERROR_VARIABLE
+ )
+
+ # set output variables
+ set(${arg_RESULT_VARIABLE} ${cmake_result} PARENT_SCOPE)
+ set(${arg_OUTPUT_VARIABLE} ${cmake_output} PARENT_SCOPE)
+ set(${arg_ERROR_VARIABLE} ${cmake_error} PARENT_SCOPE)
+endfunction()
+
+function(run_cmake_build)
+ set(options VERBOSE)
+ set(oneValueArgs CONFIG BUILD_DIR RESULT_VARIABLE OUTPUT_VARIABLE
+ ERROR_VARIABLE)
+ cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}"
+ ${ARGN})
+
+ if(NOT arg_BUILD_DIR)
+ message(FATAL_ERROR "BUILD_DIR not specified")
+ endif()
+
+ if (arg_VERBOSE OR arg_VERBOSE STREQUAL "")
+ set(arg_VERBOSE_ARG --verbose)
+ endif()
+
+ if(arg_CONFIG)
+ set(arg_BUILD_CONFIG_ARG --config ${arg_CONFIG})
+ endif()
+
+ execute_process(COMMAND ${CMAKE_COMMAND}
+ --build ${arg_BUILD_DIR}
+ ${arg_VERBOSE_ARG}
+ ${arg_BUILD_CONFIG_ARG}
+ RESULT_VARIABLE cmake_result
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE
+ ECHO_OUTPUT_VARIABLE
+ ECHO_ERROR_VARIABLE)
+
+ set(${arg_RESULT_VARIABLE} ${cmake_result} PARENT_SCOPE)
+ set(${arg_OUTPUT_VARIABLE} ${cmake_output} PARENT_SCOPE)
+ set(${arg_ERROR_VARIABLE} ${cmake_error} PARENT_SCOPE)
+endfunction()
+
+function(is_multi_config generator output)
+ if ("${generator}" MATCHES "Visual Studio" OR "${generator}" MATCHES "Xcode"
+ OR "${generator}" MATCHES "Ninja Multi-Config")
+ set(${output} TRUE PARENT_SCOPE)
+ else()
+ set(${output} FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+# check if string includes substring
+function(_internal_string_contains output string substring)
+ if("${string}" MATCHES "${substring}")
+ set(${output} TRUE PARENT_SCOPE)
+ else()
+ set(${output} FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(expect_string_contains string substring)
+ set(oneValueArgs SUCCESS_MESSAGE FAILURE_MESSAGE)
+ cmake_parse_arguments(expect_string_contains "${options}" "${oneValueArgs}"
+ "${multiValueArgs}" ${ARGN})
+ _internal_string_contains(result "${string}" "${substring}")
+ if("${result}" STREQUAL TRUE)
+ if (expect_string_contains_SUCCESS_MESSAGE)
+ message(STATUS "PASS: ${expect_string_contains_SUCCESS_MESSAGE}")
+ else()
+ message(STATUS "PASS: \"${string}\" contains \"${substring}\"")
+ endif()
+ else()
+ if (expect_string_contains_FAILURE_MESSAGE)
+ message(FATAL_ERROR
+ "FAIL: ${expect_string_contains_FAILURE_MESSAGE}")
+ else()
+ message(FATAL_ERROR "FAIL: \"${string}\" contains \"${substring}\"")
+ endif()
+ endif()
+endfunction()
+
+function(expect_string_not_contains string substring)
+ set(oneValueArgs SUCCESS_MESSAGE FAILURE_MESSAGE)
+ cmake_parse_arguments(expect_string_not_contains
+ "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ _internal_string_contains(result ${string} ${substring})
+ if(${result} STREQUAL FALSE)
+ if (expect_string_not_contains_SUCCESS_MESSAGE)
+ message(STATUS "PASS: ${expect_string_not_contains_SUCCESS_MESSAGE}")
+ else()
+ message(STATUS "PASS: \"${string}\" not contains \"${substring}\"")
+ endif()
+ else()
+ if (expect_string_not_contains_FAILURE_MESSAGE)
+ message(FATAL_ERROR
+ "FAIL: ${expect_string_not_contains_FAILURE_MESSAGE}")
+ else()
+ message(FATAL_ERROR "FAIL: \"${string}\" contains \"${substring}\"")
+ endif()
+ endif()
+endfunction()
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/main.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/main.cpp
new file mode 100644
index 0000000000..27296cb9a0
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char* argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/mainwindow.h b/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/mainwindow.h
new file mode 100644
index 0000000000..9aeaefbe08
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicBuildFolderLeakageCommon/mainwindow.h
@@ -0,0 +1,26 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(QWidget* parent = nullptr);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow* ui;
+};
+#endif // MAINWINDOW_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/main.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/main.cpp
new file mode 100644
index 0000000000..27296cb9a0
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char* argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.cpp
new file mode 100644
index 0000000000..d4302325fb
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.cpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "mainwindow.h"
+
+#include <QVBoxLayout>
+
+#include "../../../../src/ui_files/ui_mainwindow.h"
+#include "widget1.h"
+
+MainWindow::MainWindow(QWidget* parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+ auto layout = new QVBoxLayout;
+ layout->addWidget(new Widget1);
+
+ QWidget* w = new QWidget(this);
+ w->setLayout(layout);
+
+ setCentralWidget(w);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.h
new file mode 100644
index 0000000000..46dc7690cc
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/mainwindow.h
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget* parent = nullptr);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow* ui;
+};
+#endif // MAINWINDOW_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/mainwindow.ui
new file mode 100644
index 0000000000..828d7c1782
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/mainwindow.ui
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout"/>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/widget1.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/widget1.ui
new file mode 100644
index 0000000000..db0c58d5df
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/ui_files/widget1.ui
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget1</class>
+ <widget class="QWidget" name="Widget1">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>OnTextChanged:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="OnTextChanged">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.cpp
new file mode 100644
index 0000000000..2139ff2c84
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "widget1.h"
+
+#include "../../../../src/ui_files/ui_widget1.h"
+
+Widget1::Widget1(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::Widget1)
+{
+ ui->setupUi(this);
+ connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this,
+ SLOT(onTextChanged(const QString&)));
+}
+
+Widget1::~Widget1()
+{
+ delete ui;
+}
+
+void Widget1::onTextChanged(const QString& text)
+{
+ ui->OnTextChanged->setText(text);
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.h
new file mode 100644
index 0000000000..f8a5ad57d5
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.h
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WIDGET1_H
+#define WIDGET1_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Widget1;
+}
+QT_END_NAMESPACE
+
+class Widget1 : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Widget1(QWidget* parent = nullptr);
+ ~Widget1();
+public slots:
+ void onTextChanged(const QString& text);
+
+private:
+ Ui::Widget1* ui;
+};
+
+#endif // WIDGET1_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui
new file mode 100644
index 0000000000..db0c58d5df
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget1.ui
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget1</class>
+ <widget class="QWidget" name="Widget1">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>OnTextChanged:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="OnTextChanged">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.cpp
new file mode 100644
index 0000000000..721f0c868f
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "widget2.h"
+
+#include "../../../../ui_widget1.h"
+
+Widget2::Widget2(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::Widget2)
+{
+ ui->setupUi(this);
+ connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this,
+ SLOT(onTextChanged(const QString&)));
+}
+
+Widget2::~Widget2()
+{
+ delete ui;
+}
+
+void Widget2::onTextChanged(const QString& text)
+{
+ ui->OnTextChanged->setText(text);
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.h
new file mode 100644
index 0000000000..e448b12caf
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/src/widget2.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WIDGET2_H
+#define WIDGET2_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Widget2;
+}
+QT_END_NAMESPACE
+
+class Widget2 : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Widget2(QWidget* parent = nullptr);
+ ~Widget2();
+public slots:
+ void onTextChanged(const QString& text);
+
+private:
+ Ui::Widget2* ui;
+};
+
+#endif // WIDGET2_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/sub1/sub2/sub3/sub4/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/sub1/sub2/sub3/sub4/CMakeLists.txt
new file mode 100644
index 0000000000..b8443c370d
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/sub1/sub2/sub3/sub4/CMakeLists.txt
@@ -0,0 +1,39 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(UicIncrementalBuild_sameFileDifferentFolder LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui)
+
+set(CMAKE_AUTOMOC ON)
+
+qt_add_executable(example
+ ../../../../src/ui_files/mainwindow.ui
+ ../../../../src/ui_files/widget1.ui
+ ../../../../widget1.ui
+ ../../../../src/mainwindow.h
+ ../../../../src/widget1.h
+ ../../../../src/widget2.h
+ ../../../../src/main.cpp
+ ../../../../src/mainwindow.cpp
+ ../../../../src/widget1.cpp
+ ../../../../src/widget2.cpp
+)
+
+target_link_libraries(example PRIVATE Qt6::Widgets
+ Qt6::Core
+ Qt6::Gui)
+
+qt6_add_ui(example
+ INCLUDE_PREFIX "../../../../src/ui_files"
+ SOURCES "../../../../src/ui_files/mainwindow.ui"
+ "../../../../src/ui_files/widget1.ui"
+ OPTIONS "$<$<CONFIG:Debug>:-a>")
+
+qt6_add_ui(example
+ INCLUDE_PREFIX "../../../../"
+ SOURCES "../../../../widget1.ui"
+ OPTIONS "$<$<CONFIG:Debug>:-a>")
+
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/widget1.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/widget1.ui
new file mode 100644
index 0000000000..facf4678f2
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncBuild_sameFileDiffFolder/widget1.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget2</class>
+ <widget class="QWidget" name="Widget2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>OnTextChanged:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="OnTextChanged">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/CMakeLists.txt
new file mode 100644
index 0000000000..81023c3382
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/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(UicIncrementalBuild LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
+
+set(CMAKE_AUTOMOC ON)
+
+qt_add_executable(example
+ src/mainwindow.ui
+ src/widget1.ui
+ src/widget2.ui
+ src/mainwindow.h
+ src/widget1.h
+ src/widget2.h
+ src/main.cpp
+ src/mainwindow.cpp
+ src/widget1.cpp
+ src/widget2.cpp
+)
+
+target_link_libraries(example PRIVATE Qt6::Widgets
+ Qt6::Core
+ Qt6::Gui)
+
+qt6_add_ui(example
+ INCLUDE_PREFIX "src"
+ SOURCES "src/mainwindow.ui" "src/widget1.ui" "src/widget2.ui"
+ OPTIONS "$<$<CONFIG:Debug>:-a>")
+
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/main.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/main.cpp
new file mode 100644
index 0000000000..27296cb9a0
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/main.cpp
@@ -0,0 +1,14 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QApplication>
+
+#include "mainwindow.h"
+
+int main(int argc, char* argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.cpp
new file mode 100644
index 0000000000..ef582f187c
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.cpp
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "mainwindow.h"
+
+#include <QVBoxLayout>
+
+#include "src/ui_mainwindow.h"
+#include "widget1.h"
+
+MainWindow::MainWindow(QWidget* parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+ auto layout = new QVBoxLayout;
+ layout->addWidget(new Widget1);
+
+ QWidget* w = new QWidget(this);
+ w->setLayout(layout);
+
+ setCentralWidget(w);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.h
new file mode 100644
index 0000000000..46dc7690cc
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.h
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget* parent = nullptr);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow* ui;
+};
+#endif // MAINWINDOW_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.ui
new file mode 100644
index 0000000000..828d7c1782
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/mainwindow.ui
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout"/>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.cpp
new file mode 100644
index 0000000000..4047ea4d9c
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "widget1.h"
+
+#include "src/ui_widget1.h"
+
+Widget1::Widget1(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::Widget1)
+{
+ ui->setupUi(this);
+ connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this,
+ SLOT(onTextChanged(const QString&)));
+}
+
+Widget1::~Widget1()
+{
+ delete ui;
+}
+
+void Widget1::onTextChanged(const QString& text)
+{
+ ui->OnTextChanged->setText(text);
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.h
new file mode 100644
index 0000000000..f8a5ad57d5
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.h
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WIDGET1_H
+#define WIDGET1_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Widget1;
+}
+QT_END_NAMESPACE
+
+class Widget1 : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit Widget1(QWidget* parent = nullptr);
+ ~Widget1();
+public slots:
+ void onTextChanged(const QString& text);
+
+private:
+ Ui::Widget1* ui;
+};
+
+#endif // WIDGET1_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.ui
new file mode 100644
index 0000000000..db0c58d5df
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget1.ui
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget1</class>
+ <widget class="QWidget" name="Widget1">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>OnTextChanged:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="OnTextChanged">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.cpp b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.cpp
new file mode 100644
index 0000000000..1dc28b0c8b
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "widget2.h"
+
+#include "src/ui_widget2.h"
+
+Widget2::Widget2(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::Widget2)
+{
+ ui->setupUi(this);
+ connect(ui->lineEdit, SIGNAL(textChanged(const QString&)), this,
+ SLOT(onTextChanged(const QString&)));
+}
+
+Widget2::~Widget2()
+{
+ delete ui;
+}
+
+void Widget2::onTextChanged(const QString& text)
+{
+ ui->OnTextChanged->setText(text);
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.h b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.h
new file mode 100644
index 0000000000..e448b12caf
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WIDGET2_H
+#define WIDGET2_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class Widget2;
+}
+QT_END_NAMESPACE
+
+class Widget2 : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Widget2(QWidget* parent = nullptr);
+ ~Widget2();
+public slots:
+ void onTextChanged(const QString& text);
+
+private:
+ Ui::Widget2* ui;
+};
+
+#endif // WIDGET2_H
diff --git a/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.ui b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.ui
new file mode 100644
index 0000000000..facf4678f2
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/UicIncrementalBuild/src/widget2.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget2</class>
+ <widget class="QWidget" name="Widget2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Input:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>OnTextChanged:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="OnTextChanged">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/functions.cmake b/tests/auto/cmake/test_qt_add_ui_common/functions.cmake
new file mode 100644
index 0000000000..efb8b09774
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/functions.cmake
@@ -0,0 +1,223 @@
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(generate_hash_folder target_name infile out_folder)
+ get_filename_component(infile_abs "${infile}" ABSOLUTE)
+ string(SHA1 infile_hash "${target_name}${infile_abs}")
+ string(SUBSTRING "${infile_hash}" 0 6 short_hash)
+ set(${out_folder} "${short_hash}" PARENT_SCOPE)
+endfunction()
+
+function(get_latest_vs_generator output)
+ execute_process(COMMAND ${CMAKE_COMMAND} -G
+ ERROR_VARIABLE CMAKE_GENERATORS_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCHALL "Visual Studio [0-9]+ [0-9]+" vs_generators
+ "${CMAKE_GENERATORS_ERROR}")
+
+ if(NOT vs_generators)
+ message(FATAL_ERROR "No visual studio generators found")
+ endif()
+
+ set(last_version "0")
+ set(last_generator "")
+ foreach(generator IN LISTS vs_generators)
+ string(REGEX MATCH "Visual Studio ([0-9]+) [0-9]+" unused "${generator}")
+ if("${CMAKE_MATCH_1}" VERSION_GREATER "${last_version}")
+ set(last_version "${CMAKE_MATCH_1}")
+ set(last_generator "${CMAKE_MATCH_0}")
+ endif()
+ endforeach()
+ set(${output} "${last_generator}" PARENT_SCOPE)
+endfunction()
+
+function(check_unwanted_builds_after_first_build cmake_output test_name test_dir
+ generator)
+ set(unwanted_builds_success_message
+ "\"${test_name}\" in \"${test_dir}\" -> No unwanted builds")
+ set(unwanted_builds_failure_message
+ "\"${test_name}\" in \"${test_dir}\" -> Unwanted builds found")
+ if(${generator} MATCHES "Ninja")
+ expect_string_not_contains(${cmake_output}
+ "widget2.cpp.o.d|mainwindow.cpp.o.d"
+ SUCCESS_MESSAGE ${unwanted_builds_success_message}
+ FAILURE_MESSAGE ${unwanted_builds_failure_message})
+ elseif(${generator} MATCHES "Make")
+ string(CONCAT not_expect_string
+ "Building CXX object UicIncrementalBuild/CMakeFiles"
+ "/example.dir/src/widget2.cpp.o|Building CXX object UicIncremental"
+ "Build/CMakeFiles/example.dir/src/mainwindow.cpp.o")
+ expect_string_not_contains(${cmake_output} "${not_expect_string}"
+ SUCCESS_MESSAGE ${unwanted_builds_success_message}
+ FAILURE_MESSAGE ${unwanted_builds_failure_message})
+ elseif(${generator} MATCHES "Visual Studio")
+ expect_string_not_contains(${cmake_output} "widget2.cpp|mainwindow.cpp"
+ SUCCESS_MESSAGE ${unwanted_builds_success_message}
+ FAILURE_MESSAGE ${unwanted_builds_failure_message})
+ elseif(${generator} MATCHES "Xcode")
+ expect_string_not_contains(${cmake_output} "widget2.cpp|mainwindow.cpp"
+ SUCCESS_MESSAGE ${unwanted_builds_success_message}
+ FAILURE_MESSAGE ${unwanted_builds_failure_message})
+ endif()
+endfunction()
+
+function(check_output_after_second_build cmake_output test_name
+ test_dir generator)
+ set(second_build_success_message
+ "\"${test_name}\" in \"${test_dir}\" -> Generation of UI files were not \
+triggered in the second build")
+ set(second_build_failure_message
+ "\"${test_name}\" in \"${test_dir}\" -> Generation of UI files were \
+triggered in the second build")
+
+ if(${generator} MATCHES "Ninja")
+ expect_string_contains(${cmake_output} "ninja: no work to do."
+ SUCCESS_MESSAGE ${second_build_success_message}
+ FAILURE_MESSAGE ${second_build_failure_message})
+ elseif(${generator} MATCHES "Visual Studio" OR ${generator} MATCHES "Xcode")
+ expect_string_not_contains(${cmake_output} "mainwindow"
+ SUCCESS_MESSAGE
+ ${second_build_success_message}
+ FAILURE_MESSAGE
+ ${second_build_failure_message})
+ elseif(${generator} MATCHES "Makefiles")
+ expect_string_not_contains(${cmake_output} "mainwindow.cpp.o.d -o"
+ SUCCESS_MESSAGE ${second_build_success_message}
+ FAILURE_MESSAGE ${second_build_failure_message})
+ endif()
+endfunction()
+
+function(incremental_build_test)
+ set(options CHECK_UNWANTED_BUILDS)
+ set(oneValueArgs CONFIG TEST_NAME SOURCE_DIR BUILD_DIR FILE_TO_TOUCH
+ FILE_TO_CHECK FOLDER_TO_CHECK GENERATOR)
+ set(multiValueArgs ADDITIONAL_ARGS)
+
+ cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}"
+ ${ARGN})
+
+ string(REPLACE ";" " " arg_ADDITIONAL_ARGS "${arg_ADDITIONAL_ARGS}")
+ if ("${arg_SOURCE_DIR}" STREQUAL "")
+ message(FATAL_ERROR "FAIL: \"${arg_TEST_NAME}\" test failed because "
+ "SOURCE_DIR is empty")
+ endif()
+
+ if ("${arg_BUILD_DIR}" STREQUAL "")
+ message(FATAL_ERROR "FAIL: \"${arg_TEST_NAME}\" test failed because "
+ "BUILD_DIR is empty")
+ endif()
+
+ if ("${arg_GENERATOR}" STREQUAL "")
+ message(FATAL_ERROR "FAIL: \"${arg_TEST_NAME}\" test failed because "
+ "GENERATOR is empty")
+ endif()
+
+ run_cmake_configure(SOURCE_DIR "${arg_SOURCE_DIR}"
+ BUILD_DIR "${arg_BUILD_DIR}"
+ GENERATOR "${arg_GENERATOR}"
+ CLEAN_FIRST
+ ADDITIONAL_ARGS ${arg_ADDITIONAL_ARGS}
+ OUTPUT_VARIABLE cmake_output
+ ERROR_VARIABLE cmake_error
+ RESULT_VARIABLE cmake_result)
+
+ if(${cmake_result} EQUAL 0)
+ message(STATUS
+ "PASS: \"${arg_TEST_NAME}\" test in ${arg_BUILD_DIR} was configured "
+ "successfully")
+ else()
+ message(FATAL_ERROR "cmake_output: ${cmake_output}\ncmake_error: "
+ "${cmake_error}\nFAIL: \"${arg_TEST_NAME}\" test in ${arg_BUILD_DIR}"
+ " failed to configure")
+ endif()
+
+ if(NOT "${arg_CONFIG}" STREQUAL "single_config")
+ set(config_arg "${arg_CONFIG}")
+ endif()
+
+ run_cmake_build(BUILD_DIR ${arg_BUILD_DIR}
+ VERBOSE ON
+ CONFIG ${config_arg}
+ OUTPUT_VARIABLE cmake_build_output
+ ERROR_VARIABLE cmake_build_error
+ RESULT_VARIABLE cmake_build_result)
+
+ if(${cmake_build_result} EQUAL 0)
+ message(STATUS
+ "PASS: \"${arg_TEST_NAME}\" test in ${arg_BUILD_DIR} was built "
+ "successfully")
+ else()
+ message(FATAL_ERROR
+ "cmake_build_output: ${cmake_build_output}\ncmake_build_error: "
+ "${cmake_build_error}\nFAIL: \"${arg_TEST_NAME}\" test in "
+ "${arg_BUILD_DIR} failed to build")
+ endif()
+
+ if(NOT "${arg_FILE_TO_CHECK}" STREQUAL "")
+ if(NOT EXISTS "${arg_FILE_TO_CHECK}")
+ message(FATAL_ERROR "FAIL: \"${arg_TEST_NAME}\" ${arg_FILE_TO_CHECK}"
+ " could not be found")
+ else()
+ message(STATUS "PASS: \"${arg_TEST_NAME}\" \"${arg_FILE_TO_CHECK}\" "
+ "was generated successfully")
+ endif()
+ endif()
+
+ if(NOT "${arg_FOLDER_TO_CHECK}" STREQUAL "" AND NOT WIN32)
+ if(NOT EXISTS "${arg_FOLDER_TO_CHECK}")
+ message(FATAL_ERROR
+ "FAIL: \"${arg_TEST_NAME}\" Folder \"${arg_FOLDER_TO_CHECK}\" "
+ "does not exist")
+ else()
+ message(STATUS
+ "PASS: \"${arg_TEST_NAME}\" Folder \"${arg_FOLDER_TO_CHECK}\" "
+ "exists")
+ endif()
+ endif()
+
+ if(NOT "${arg_FILE_TO_TOUCH}" STREQUAL "")
+ file(TOUCH "${arg_FILE_TO_TOUCH}")
+ endif()
+
+ run_cmake_build(BUILD_DIR ${arg_BUILD_DIR}
+ VERBOSE ON
+ CONFIG ${arg_CONFIG}
+ OUTPUT_VARIABLE cmake_build_output)
+ if(${arg_CHECK_UNWANTED_BUILDS})
+ check_unwanted_builds_after_first_build(${cmake_build_output}
+ ${arg_TEST_NAME} ${arg_BUILD_DIR} ${arg_GENERATOR})
+ endif()
+
+ run_cmake_build(BUILD_DIR ${arg_BUILD_DIR}
+ VERBOSE ON
+ CONFIG ${arg_CONFIG}
+ OUTPUT_VARIABLE cmake_build_output)
+ check_output_after_second_build(${cmake_build_output}
+ ${arg_TEST_NAME} ${arg_BUILD_DIR} ${arg_GENERATOR})
+endfunction()
+
+function(get_generators output)
+ if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
+ set(generators "Unix Makefiles" "Ninja" "Ninja Multi-Config")
+ elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
+ # CI fails with Clang and Visual Studio generators.
+ # That's why discard that combination.
+ if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND
+ NOT MINGW)
+ get_latest_vs_generator(latest_vs)
+ endif()
+ set(generators "Ninja" "Ninja Multi-Config" "${latest_vs}")
+ elseif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
+ # TODO: Add Xcode generator when
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/25790 is fixed.
+ # Otherwise, adding Xcode generator might fail CI due to the timeout
+ # issue.
+ set(generators "Unix Makefiles" "Ninja" "Ninja Multi-Config")
+ else()
+ string(JOIN "" ERROR_MESSAGE
+ "FAIL: host OS not supported for this test."
+ "host : ${CMAKE_HOST_SYSTEM_NAME}")
+ message(FATAL_ERROR "${ERROR_MESSAGE}")
+ endif()
+ set(${output} "${generators}" PARENT_SCOPE)
+endfunction()
diff --git a/tests/auto/cmake/test_qt_add_ui_common/main.cpp b/tests/auto/cmake/test_qt_add_ui_common/main.cpp
new file mode 100644
index 0000000000..c93c3fc6a0
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/main.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main() { return 0; }
diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt b/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt
new file mode 100644
index 0000000000..b05efd5e4d
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/CMakeLists.txt
@@ -0,0 +1,65 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+
+project(UicTest LANGUAGES CXX)
+
+find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui)
+
+set(CMAKE_AUTOMOC ON)
+
+if (NOT DO_NOT_GENERATE_FILE)
+ file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mainwindow.cpp"
+ CONTENT " \
+#include \"${CMAKE_CURRENT_SOURCE_DIR}/../UicBuildFolderLeakageCommon/mainwindow.h\" \n \
+#include \"${MAINWINDOW_UI_PATH}ui_mainwindow.h\" \n \
+MainWindow::MainWindow(QWidget* parent) \n \
+ : QMainWindow(parent) \n \
+ , ui(new Ui::MainWindow) \n \
+{ \n \
+ ui->setupUi(this); \n \
+} \n \
+ \n \
+MainWindow::~MainWindow() \n \
+{ \n \
+ delete ui; \n \
+} \n \
+")
+endif()
+
+qt_add_executable(example
+ ../UicBuildFolderLeakageCommon/main.cpp
+ ../UicBuildFolderLeakageCommon/mainwindow.h
+ mainwindow.ui
+)
+
+if (${DO_NOT_GENERATE_FILE})
+ target_sources(example PRIVATE mainwindow.cpp)
+else()
+ target_sources(example PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/mainwindow.cpp")
+endif()
+
+target_link_libraries(example PRIVATE Qt6::Widgets
+ Qt6::Core
+ Qt6::Gui)
+
+if (NOT UI_NO_CONFIG_OPTIONS)
+ set(uic_options "$<$<CONFIG:Debug>:-a>")
+endif()
+qt6_add_ui(example
+ INCLUDE_PREFIX "${MAINWINDOW_UI_PATH}"
+ SOURCES "mainwindow.ui"
+ OPTIONS "${uic_options}")
+
+if(ADD_NEW_UI)
+ qt6_add_ui(example INCLUDE_PREFIX "${NEW_UI_PATH}"
+ SOURCES "subdir/mainwindow.ui"
+ OPTIONS "${uic_options}")
+endif()
+
+# Enable AUTOUIC after qt6_add_ui() has been called
+if (CMAKE_AUTOUIC)
+ set_property(TARGET example PROPERTY AUTOUIC ON)
+endif()
+
diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp
new file mode 100644
index 0000000000..1c4b48b49e
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.cpp
@@ -0,0 +1,17 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include "../UicBuildFolderLeakageCommon/mainwindow.h"
+#include "sub1/sub2/sub3/ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget* parent)
+ : QMainWindow(parent)
+ , ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui
new file mode 100644
index 0000000000..4e57b05eac
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/mainwindow.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui b/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui
new file mode 100644
index 0000000000..4e57b05eac
--- /dev/null
+++ b/tests/auto/cmake/test_qt_add_ui_common/uic_test/subdir/mainwindow.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
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
index f133f67d05..40fb1dffbe 100644
--- 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
@@ -1,4 +1,4 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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
index 670f038749..b141c894ab 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
int main(int argc, char *argv[])
{
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
index cc5c4a772d..bcd7594d9a 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
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
index 08c84c85c3..1c38ae2f5e 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
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
index d2e4db9314..104dd6d7a9 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
#include <QObject>
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
index 56d6c56bb5..f3a9ececb7 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#pragma once
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/myobject.cpp b/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
index 71d734f5fe..bb06a5bb8b 100644
--- a/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
+++ b/tests/auto/cmake/test_qtmainwin_library/myobject.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 ccf0a310ff..90bb75640f 100644
--- a/tests/auto/cmake/test_qtmainwin_library/myobject.h
+++ b/tests/auto/cmake/test_qtmainwin_library/myobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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
index 146dd2bd5a..10bc1fd407 100644
--- a/tests/auto/cmake/test_static_resources/.cmake.conf
+++ b/tests/auto/cmake/test_static_resources/.cmake.conf
@@ -1 +1 @@
-set(QT_REPO_MODULE_VERSION "6.6.0")
+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
index bddc1df932..e3cab9cf4a 100644
--- a/tests/auto/cmake/test_static_resources/CMakeLists.txt
+++ b/tests/auto/cmake/test_static_resources/CMakeLists.txt
@@ -13,6 +13,7 @@ project(TestStaticResources
)
find_package(Qt6 COMPONENTS Core BuildInternals Test CONFIG REQUIRED)
+qt_internal_project_setup()
qt_build_repo_begin()
@@ -21,4 +22,5 @@ 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/dummy.cpp b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp
index 31f62648f6..b6c23a82eb 100644
--- a/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp
+++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/dummy.cpp
@@ -1,4 +1,4 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
void dummy() { }
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
index da2ed67973..a95e54ee4f 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/qfile.h>
#include <QtCore/qdebug.h>
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
index 352ae57fac..2067b8c920 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtCore/qfile.h>
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
index fc048bb61e..c5d5312eb8 100644
--- 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
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtCore/qfile.h>
diff --git a/tests/auto/cmake/test_testlib_definitions/main.cpp b/tests/auto/cmake/test_testlib_definitions/main.cpp
index 750e42cfdf..9452adb817 100644
--- a/tests/auto/cmake/test_testlib_definitions/main.cpp
+++ b/tests/auto/cmake/test_testlib_definitions/main.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
#include <QTest>
diff --git a/tests/auto/cmake/test_versionless_targets/CMakeLists.txt b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
index 3514f4e0f9..1afcaa6a93 100644
--- a/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
+++ b/tests/auto/cmake/test_versionless_targets/CMakeLists.txt
@@ -5,22 +5,99 @@ 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
+ )
-find_package(Qt6Core REQUIRED)
+ 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
+ )
-if (NOT TARGET Qt6::Core)
- message(SEND_ERROR "Qt6::Core target not defined!")
-endif()
+ 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 (TARGET Qt::Core)
- message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
-endif()
+ if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
+ message(SEND_ERROR "INTERFACE_${prop} doesn't match versionless ${versionless_prop}"
+ " versioned ${versioned_prop}")
+ endif()
+ endforeach()
-set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
+ 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()
-find_package(Qt6Core REQUIRED)
+ if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
+ message(SEND_ERROR "${prop} doesn't match versionless ${versionless_prop}"
+ " versioned ${versioned_prop}")
+ endif()
+ endforeach()
-if (NOT TARGET Qt::Core)
- message(SEND_ERROR "Qt::Core target not defined!")
-endif()
+ 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()
+
+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/main.cpp b/tests/auto/cmake/test_widgets_app_deployment/main.cpp
index 1823a50169..939cd72380 100644
--- a/tests/auto/cmake/test_widgets_app_deployment/main.cpp
+++ b/tests/auto/cmake/test_widgets_app_deployment/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest>
#include <QMainWindow>
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 8330e3250d..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 917ae9fd24..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,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/myobject.cpp b/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
index 2a90499e6a..14e00e789a 100644
--- a/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
+++ b/tests/auto/cmake/test_wrap_cpp_options/myobject.cpp
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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 917ae9fd24..87d7bfa3df 100644
--- a/tests/auto/cmake/test_wrap_cpp_options/myobject.h
+++ b/tests/auto/cmake/test_wrap_cpp_options/myobject.h
@@ -1,5 +1,5 @@
// 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 WITH Qt-GPL-exception-1.0
+// 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/plugin.cpp b/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp
index ccb0096730..1647d8d3a8 100644
--- a/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp
+++ b/tests/auto/cmake/tst_qaddpreroutine/plugin.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 zccrs <zccrs@live.com>, JiDe Zhang <zhangjide@uniontech.com>.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qpa/qplatformthemeplugin.h>
#include <qpa/qplatformtheme.h>
diff --git a/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp b/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp
index 42c7a07b08..21394648c0 100644
--- a/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp
+++ b/tests/auto/cmake/tst_qaddpreroutine/tst_qaddpreroutine.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 zccrs <zccrs@live.com>, JiDe Zhang <zhangjide@uniontech.com>.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
#include <QGuiApplication>