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 <QtCore/QString>
instead of <QString> 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 <joerg.bornemann@qt.io>
This commit is contained in:
Amir Masoud Abdol 2023-03-09 15:21:41 +01:00
parent 608c2501e5
commit d203f82916
17 changed files with 28 additions and 4 deletions

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock1Plugin qt_internal_add_plugin(QMock1Plugin
NO_UNITY_BUILD
CLASS_NAME QMock1Plugin CLASS_NAME QMock1Plugin
PLUGIN_TYPE mockplugin PLUGIN_TYPE mockplugin
SOURCES SOURCES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock2Plugin qt_internal_add_plugin(QMock2Plugin
NO_UNITY_BUILD
CLASS_NAME QMock2Plugin CLASS_NAME QMock2Plugin
PLUGIN_TYPE mockplugin PLUGIN_TYPE mockplugin
SOURCES SOURCES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock3Plugin qt_internal_add_plugin(QMock3Plugin
NO_UNITY_BUILD
CLASS_NAME QMock3Plugin CLASS_NAME QMock3Plugin
PLUGIN_TYPE mockplugin PLUGIN_TYPE mockplugin
SOURCES SOURCES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock4Plugin qt_internal_add_plugin(QMock4Plugin
NO_UNITY_BUILD
CLASS_NAME QMock4Plugin CLASS_NAME QMock4Plugin
PLUGIN_TYPE mockplugin PLUGIN_TYPE mockplugin
DEFAULT_IF FALSE DEFAULT_IF FALSE

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock5Plugin qt_internal_add_plugin(QMock5Plugin
NO_UNITY_BUILD
CLASS_NAME QMock5Plugin CLASS_NAME QMock5Plugin
PLUGIN_TYPE mockplugin PLUGIN_TYPE mockplugin
DEFAULT_IF FALSE DEFAULT_IF FALSE

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(QMock6Plugin qt_internal_add_plugin(QMock6Plugin
NO_UNITY_BUILD
CLASS_NAME QMock6Plugin CLASS_NAME QMock6Plugin
PLUGIN_TYPE mockauxplugin PLUGIN_TYPE mockauxplugin
SOURCES SOURCES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(MockPlugins1 qt_internal_add_module(MockPlugins1
NO_UNITY_BUILD
PLUGIN_TYPES mockplugin PLUGIN_TYPES mockplugin
SOURCES SOURCES
qmockplugin.h qmockplugin.h

View File

@ -4,8 +4,8 @@
#ifndef QMOCKPLUGIN_H #ifndef QMOCKPLUGIN_H
#define QMOCKPLUGIN_H #define QMOCKPLUGIN_H
#include <QString> #include <QtCore/QString>
#include <QtPlugin> #include <QtCore/QtPlugin>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(MockPlugins2 qt_internal_add_module(MockPlugins2
NO_UNITY_BUILD
SOURCES SOURCES
fake.cpp fake.cpp
LIBRARIES LIBRARIES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(MockPlugins3 qt_internal_add_module(MockPlugins3
NO_UNITY_BUILD
PLUGIN_TYPES mockauxplugin PLUGIN_TYPES mockauxplugin
SOURCES SOURCES
qmockauxplugin.h qmockauxplugin.h

View File

@ -4,8 +4,8 @@
#ifndef QMOCKAUXPLUGIN_H #ifndef QMOCKAUXPLUGIN_H
#define QMOCKAUXPLUGIN_H #define QMOCKAUXPLUGIN_H
#include <QString> #include <QtCore/QString>
#include <QtPlugin> #include <QtCore/QtPlugin>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(TestAutogeneratingCppExports qt_internal_add_module(TestAutogeneratingCppExports
NO_UNITY_BUILD
GENERATE_CPP_EXPORTS GENERATE_CPP_EXPORTS
SOURCES SOURCES
module_api.h module_api.h
@ -18,3 +19,4 @@ qt_internal_extend_target(TestAutogeneratingCppExports
add_executable(TestAutogeneratingCppExportsApp use_api.cpp) add_executable(TestAutogeneratingCppExportsApp use_api.cpp)
target_link_libraries(TestAutogeneratingCppExportsApp PRIVATE TestAutogeneratingCppExports) target_link_libraries(TestAutogeneratingCppExportsApp PRIVATE TestAutogeneratingCppExports)
set_target_properties(TestAutogeneratingCppExportsApp PROPERTIES UNITY_BUILD OFF)

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(TestAutogeneratingCppExportsCustomName qt_internal_add_module(TestAutogeneratingCppExportsCustomName
NO_UNITY_BUILD
GENERATE_CPP_EXPORTS GENERATE_CPP_EXPORTS
CPP_EXPORT_HEADER_BASE_NAME CPP_EXPORT_HEADER_BASE_NAME
"customname_exports" "customname_exports"
@ -20,3 +21,4 @@ qt_internal_extend_target(TestAutogeneratingCppExportsCustomName
add_executable(testapp2 use_api.cpp) add_executable(testapp2 use_api.cpp)
target_link_libraries(testapp2 PRIVATE TestAutogeneratingCppExportsCustomName) target_link_libraries(testapp2 PRIVATE TestAutogeneratingCppExportsCustomName)
set_target_properties(testapp2 PROPERTIES UNITY_BUILD OFF)

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_module(MockStaticResources1 qt_internal_add_module(MockStaticResources1
NO_UNITY_BUILD
STATIC STATIC
PLUGIN_TYPES mockstaticresources PLUGIN_TYPES mockstaticresources
SOURCES SOURCES

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC qt_internal_add_plugin(TestInitResourcesStaticPlugin STATIC
NO_UNITY_BUILD
OUTPUT_NAME OUTPUT_NAME
testinitresourcesstaticplugin testinitresourcesstaticplugin
PLUGIN_TYPE mockstaticresources PLUGIN_TYPE mockstaticresources

View File

@ -11,6 +11,7 @@
# Add a dummy library that links the static "Qt" module containing resources # Add a dummy library that links the static "Qt" module containing resources
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" CONTENT "void dummy() { }") file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp" CONTENT "void dummy() { }")
add_library(dummy STATIC "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") add_library(dummy STATIC "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
set_target_properties(dummy PROPERTIES UNITY_BUILD OFF)
target_link_libraries(dummy PRIVATE MockStaticResources1) target_link_libraries(dummy PRIVATE MockStaticResources1)
# Add the executable using qt_add_executable that needs to initialize the propagated resources. # 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) qt_add_executable(test_static_resources_propagation main.cpp)
set_target_properties(test_static_resources_propagation PROPERTIES set_target_properties(test_static_resources_propagation PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation target_link_libraries(test_static_resources_propagation
PRIVATE PRIVATE
@ -37,6 +39,7 @@ endif()
qt_add_executable(test_static_resources_propagation_manual_finalize main.cpp MANUAL_FINALIZATION) qt_add_executable(test_static_resources_propagation_manual_finalize main.cpp MANUAL_FINALIZATION)
set_target_properties(test_static_resources_propagation_manual_finalize PROPERTIES set_target_properties(test_static_resources_propagation_manual_finalize PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_manual_finalize target_link_libraries(test_static_resources_propagation_manual_finalize
PRIVATE PRIVATE
@ -54,6 +57,7 @@ add_test(NAME test_static_resources_propagation_manual_finalize
add_executable(test_static_resources_propagation_non_qt main.cpp) add_executable(test_static_resources_propagation_non_qt main.cpp)
set_target_properties(test_static_resources_propagation_non_qt PROPERTIES set_target_properties(test_static_resources_propagation_non_qt PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_non_qt target_link_libraries(test_static_resources_propagation_non_qt
PRIVATE PRIVATE
@ -76,6 +80,7 @@ if(NOT link_order_matters)
add_executable(test_static_resources_propagation_non_ld main.cpp) add_executable(test_static_resources_propagation_non_ld main.cpp)
set_target_properties(test_static_resources_propagation_non_ld PROPERTIES set_target_properties(test_static_resources_propagation_non_ld PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_non_ld target_link_libraries(test_static_resources_propagation_non_ld
PRIVATE PRIVATE
@ -123,6 +128,7 @@ if(POLICY CMP0099)
add_executable(test_static_resources_propagation_cmp0099_old_finalize main.cpp) add_executable(test_static_resources_propagation_cmp0099_old_finalize main.cpp)
set_target_properties(test_static_resources_propagation_cmp0099_old_finalize PROPERTIES set_target_properties(test_static_resources_propagation_cmp0099_old_finalize PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_cmp0099_old_finalize target_link_libraries(test_static_resources_propagation_cmp0099_old_finalize
PRIVATE PRIVATE
@ -142,6 +148,7 @@ if(POLICY CMP0099)
add_executable(test_static_resources_propagation_cmp0099_new main.cpp) add_executable(test_static_resources_propagation_cmp0099_new main.cpp)
set_target_properties(test_static_resources_propagation_cmp0099_new PROPERTIES set_target_properties(test_static_resources_propagation_cmp0099_new PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_cmp0099_new target_link_libraries(test_static_resources_propagation_cmp0099_new
PRIVATE PRIVATE
@ -157,6 +164,7 @@ if(POLICY CMP0099)
add_executable(test_static_resources_propagation_cmp0099_new_genex main.cpp) add_executable(test_static_resources_propagation_cmp0099_new_genex main.cpp)
set_target_properties(test_static_resources_propagation_cmp0099_new_genex PROPERTIES set_target_properties(test_static_resources_propagation_cmp0099_new_genex PROPERTIES
AUTOMOC TRUE AUTOMOC TRUE
UNITY_BUILD OFF
) )
target_link_libraries(test_static_resources_propagation_cmp0099_new_genex target_link_libraries(test_static_resources_propagation_cmp0099_new_genex
PRIVATE PRIVATE

View File

@ -25,6 +25,7 @@ qt_prepare_standalone_project()
find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED) find_package(Qt6 COMPONENTS Gui Test CONFIG REQUIRED)
qt_internal_add_plugin(QTBUG_90341ThemePlugin qt_internal_add_plugin(QTBUG_90341ThemePlugin
NO_UNITY_BUILD
OUTPUT_NAME QTBUG_90341 OUTPUT_NAME QTBUG_90341
OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
CLASS_NAME ThemePlugin CLASS_NAME ThemePlugin