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
qt_internal_add_plugin(QMock1Plugin
NO_UNITY_BUILD
CLASS_NAME QMock1Plugin
PLUGIN_TYPE mockplugin
SOURCES

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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)

View File

@ -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)

View File

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

View File

@ -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

View File

@ -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

View File

@ -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