From d203f82916dc4e04279ab890eeeb63a991313621 Mon Sep 17 00:00:00 2001 From: Amir Masoud Abdol Date: Thu, 9 Mar 2023 15:21:41 +0100 Subject: [PATCH] Fix for CMake tests when build with unity Some of the mockplugin tests needed to be excluded from the unity build manually. In addition, MSVC's complain about include instead of was addressed here since it was breaking the unity build as well. Some other independent executable and libraries have to be excluded manually as well. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I1f21f8484b4d3b1c399e2118ab3a71e682a3006a Reviewed-by: Joerg Bornemann --- tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h | 4 ++-- tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt | 1 + tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt | 1 + .../auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h | 4 ++-- .../test_autogenerating_cpp_exports/CMakeLists.txt | 2 ++ .../CMakeLists.txt | 2 ++ .../mock_static_resources1/CMakeLists.txt | 1 + .../test_init_resources_static_plugin/CMakeLists.txt | 1 + .../test_static_resources_propagation/CMakeLists.txt | 8 ++++++++ tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt | 1 + 17 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt index ba636e6fe61..5a37ef9ea0e 100644 --- a/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock1plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock1Plugin + NO_UNITY_BUILD CLASS_NAME QMock1Plugin PLUGIN_TYPE mockplugin SOURCES diff --git a/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt index acdcd7d7e2e..f2705335f52 100644 --- a/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock2plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock2Plugin + NO_UNITY_BUILD CLASS_NAME QMock2Plugin PLUGIN_TYPE mockplugin SOURCES diff --git a/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt index 8b8333d2cb8..b165353b241 100644 --- a/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock3plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock3Plugin + NO_UNITY_BUILD CLASS_NAME QMock3Plugin PLUGIN_TYPE mockplugin SOURCES diff --git a/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt index b988e9b77f0..cf09fb294b2 100644 --- a/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock4plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock4Plugin + NO_UNITY_BUILD CLASS_NAME QMock4Plugin PLUGIN_TYPE mockplugin DEFAULT_IF FALSE diff --git a/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt index 1bd671e97c4..1d34cabe1f7 100644 --- a/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock5plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock5Plugin + NO_UNITY_BUILD CLASS_NAME QMock5Plugin PLUGIN_TYPE mockplugin DEFAULT_IF FALSE diff --git a/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt b/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt index 1a1272d8784..5d80407d574 100644 --- a/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mock6plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(QMock6Plugin + NO_UNITY_BUILD CLASS_NAME QMock6Plugin PLUGIN_TYPE mockauxplugin SOURCES diff --git a/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt index 933f6dde5da..adba60e42d4 100644 --- a/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mockplugins1/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(MockPlugins1 + NO_UNITY_BUILD PLUGIN_TYPES mockplugin SOURCES qmockplugin.h diff --git a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h index ee9db067c58..9caf6b973aa 100644 --- a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h +++ b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h @@ -4,8 +4,8 @@ #ifndef QMOCKPLUGIN_H #define QMOCKPLUGIN_H -#include -#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt index 62fd34e90b9..a797206cd69 100644 --- a/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mockplugins2/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(MockPlugins2 + NO_UNITY_BUILD SOURCES fake.cpp LIBRARIES diff --git a/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt b/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt index 5df9c1b6856..b8e3c54535e 100644 --- a/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt +++ b/tests/auto/cmake/mockplugins/mockplugins3/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(MockPlugins3 + NO_UNITY_BUILD PLUGIN_TYPES mockauxplugin SOURCES qmockauxplugin.h diff --git a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h index 80dcddf993a..cc92d16a76e 100644 --- a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h +++ b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h @@ -4,8 +4,8 @@ #ifndef QMOCKAUXPLUGIN_H #define QMOCKAUXPLUGIN_H -#include -#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt index 53cf02acaf0..0e446dd1084 100644 --- a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt +++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(TestAutogeneratingCppExports + NO_UNITY_BUILD GENERATE_CPP_EXPORTS SOURCES module_api.h @@ -18,3 +19,4 @@ qt_internal_extend_target(TestAutogeneratingCppExports add_executable(TestAutogeneratingCppExportsApp use_api.cpp) target_link_libraries(TestAutogeneratingCppExportsApp PRIVATE TestAutogeneratingCppExports) +set_target_properties(TestAutogeneratingCppExportsApp PROPERTIES UNITY_BUILD OFF) diff --git a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt index d203fd6b877..8473979c70d 100644 --- a/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt +++ b/tests/auto/cmake/test_generating_cpp_exports/test_autogenerating_cpp_exports_custom_name/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(TestAutogeneratingCppExportsCustomName + NO_UNITY_BUILD GENERATE_CPP_EXPORTS CPP_EXPORT_HEADER_BASE_NAME "customname_exports" @@ -20,3 +21,4 @@ qt_internal_extend_target(TestAutogeneratingCppExportsCustomName add_executable(testapp2 use_api.cpp) target_link_libraries(testapp2 PRIVATE TestAutogeneratingCppExportsCustomName) +set_target_properties(testapp2 PROPERTIES UNITY_BUILD OFF) diff --git a/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt index c45af807810..f866f0af465 100644 --- a/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt +++ b/tests/auto/cmake/test_static_resources/mock_static_resources1/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_module(MockStaticResources1 + NO_UNITY_BUILD STATIC PLUGIN_TYPES mockstaticresources SOURCES diff --git a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt index d017ba8ab0a..dec5588a6d6 100644 --- a/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt +++ b/tests/auto/cmake/test_static_resources/test_init_resources_static_plugin/CMakeLists.txt @@ -2,6 +2,7 @@ # SPDX-License-Identifier: BSD-3-Clause qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC + NO_UNITY_BUILD OUTPUT_NAME testinitresourcesstaticplugin PLUGIN_TYPE mockstaticresources diff --git a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt index 2606cd88d95..b802323cfc8 100644 --- a/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt +++ b/tests/auto/cmake/test_static_resources/test_static_resources_propagation/CMakeLists.txt @@ -11,6 +11,7 @@ # Add a dummy library that links the static "Qt" module containing resources file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" CONTENT "void dummy() { }") add_library(dummy STATIC "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") +set_target_properties(dummy PROPERTIES UNITY_BUILD OFF) target_link_libraries(dummy PRIVATE MockStaticResources1) # Add the executable using qt_add_executable that needs to initialize the propagated resources. @@ -19,6 +20,7 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19) qt_add_executable(test_static_resources_propagation main.cpp) set_target_properties(test_static_resources_propagation PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation PRIVATE @@ -37,6 +39,7 @@ endif() qt_add_executable(test_static_resources_propagation_manual_finalize main.cpp MANUAL_FINALIZATION) set_target_properties(test_static_resources_propagation_manual_finalize PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_manual_finalize PRIVATE @@ -54,6 +57,7 @@ add_test(NAME test_static_resources_propagation_manual_finalize add_executable(test_static_resources_propagation_non_qt main.cpp) set_target_properties(test_static_resources_propagation_non_qt PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_non_qt PRIVATE @@ -76,6 +80,7 @@ if(NOT link_order_matters) add_executable(test_static_resources_propagation_non_ld main.cpp) set_target_properties(test_static_resources_propagation_non_ld PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_non_ld PRIVATE @@ -123,6 +128,7 @@ if(POLICY CMP0099) add_executable(test_static_resources_propagation_cmp0099_old_finalize main.cpp) set_target_properties(test_static_resources_propagation_cmp0099_old_finalize PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_cmp0099_old_finalize PRIVATE @@ -142,6 +148,7 @@ if(POLICY CMP0099) add_executable(test_static_resources_propagation_cmp0099_new main.cpp) set_target_properties(test_static_resources_propagation_cmp0099_new PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_cmp0099_new PRIVATE @@ -157,6 +164,7 @@ if(POLICY CMP0099) add_executable(test_static_resources_propagation_cmp0099_new_genex main.cpp) set_target_properties(test_static_resources_propagation_cmp0099_new_genex PROPERTIES AUTOMOC TRUE + UNITY_BUILD OFF ) target_link_libraries(test_static_resources_propagation_cmp0099_new_genex PRIVATE diff --git a/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt b/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt index a9892a94ec8..bc1a6339db8 100644 --- a/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt +++ b/tests/auto/cmake/tst_qaddpreroutine/CMakeLists.txt @@ -25,6 +25,7 @@ qt_prepare_standalone_project() find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED) qt_internal_add_plugin(QTBUG_90341ThemePlugin + NO_UNITY_BUILD OUTPUT_NAME QTBUG_90341 OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" CLASS_NAME ThemePlugin