summaryrefslogtreecommitdiffstats
path: root/tests/auto/cmake/test_import_plugins/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/cmake/test_import_plugins/CMakeLists.txt')
-rw-r--r--tests/auto/cmake/test_import_plugins/CMakeLists.txt102
1 files changed, 48 insertions, 54 deletions
diff --git a/tests/auto/cmake/test_import_plugins/CMakeLists.txt b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
index a793fe211d..3db7f012db 100644
--- a/tests/auto/cmake/test_import_plugins/CMakeLists.txt
+++ b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
@@ -1,4 +1,3 @@
-
cmake_minimum_required(VERSION 3.1)
project(import_plugins_advanced)
@@ -6,26 +5,9 @@ enable_testing()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
- include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHints.cmake")
-endif()
-
-# Need to find Qt5Core explicitly because the MockPlugins1 and MockPlugins2 config files
-# are in a different directory (the source dir) when doing a standalone tests build,
-# whereas Core is in the installed directory, and due to NO_DEFAULT_PATH being used
-# for the Core dependency call in Qt5MockPlugins, Core would not be found in the source
-# dir.
-find_package(Qt5 COMPONENTS Core REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
-get_target_property(qt_is_static Qt5::Core TYPE)
-
-# For a similar reason, we need to find the MockPlugins packages not via COMPONENTS argument,
-# but directly, because the location of Qt5Config.cmake is in the installed dir, while
-# the MockPlugins are in the source dir, and Qt5Config only looks for packages relative
-# to its own location.
-# The packages are still successfuly found, because the CMAKE_PREFIX_PATH populated by qmake
-# contains both the installed Qt dir, and the Qt source dir.
-find_package(Qt5MockPlugins1 REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
-find_package(Qt5MockPlugins2 REQUIRED HINTS ${Qt5Tests_PREFIX_PATH})
+find_package(Qt6 COMPONENTS REQUIRED MockPlugins1 MockPlugins2)
+# MockPlugins3 is automatically find_dependency'd by QMock5Plugin which depends on MockPlugins3.
+# QMock5Plugin itself is loaded by QtMockPlugins1Plugins.cmake.
function(create_test_executable TARGET_NAME)
set(CHECK_FILE ${CMAKE_BINARY_DIR}/${TARGET_NAME}_check.cpp)
@@ -37,75 +19,87 @@ function(create_test_executable TARGET_NAME)
configure_file("${CMAKE_SOURCE_DIR}/check.cpp.in" ${CHECK_FILE})
add_executable(${TARGET_NAME} main.cpp ${CHECK_FILE})
- target_link_libraries(${TARGET_NAME} Qt5::MockPlugins1)
+ target_link_libraries(${TARGET_NAME} PRIVATE Qt6::MockPlugins1)
add_test(test_${TARGET_NAME} ${TARGET_NAME})
endfunction()
-create_test_executable(default QMock1Plugin QMock2Plugin)
-# No call to qt5_import_plugins() for the default
+# No call to qt_import_plugins() for the default case.
+create_test_executable(default
+ QMock1Plugin QMock2Plugin
-# TODO This test is known to fail because CMake currently doesn't have a way to
-# implement its own equivalent of the PLUGIN_EXTENDS mechanism at generate-
-# time (meaning a library only gets linked if a set of other libraries are
-# *also* linked.) CMake 3.14 or beyond may have such a mechanism, but until
-# then, this test is expected to fail, because QMock3Plugin is not being
-# linked even though MockPlugins2 is present.
-create_test_executable(default_link QMock1Plugin QMock2Plugin QMock3Plugin)
-target_link_libraries(default_link Qt5::MockPlugins2)
-set_property(TEST test_default_link PROPERTY DISABLED 1)
-# No call to qt5_import_plugins() for the default
+ QMock3Plugin # TODO: Should not be linked based on .pro file, see QTBUG-93501
+)
+
+# No call to qt_import_plugins() for the default_link case.
+create_test_executable(default_link QMock1Plugin QMock2Plugin
+
+ # TODO: in qmake QMock3Plugin should only be linked if the executable depends on MockPlugins2
+ # module (based on .pro file PLUGIN_EXTENDS). Here it's accidentally linked because
+ # we're missing PLUGIN_EXTENDS information in CMake land. Thus it's considered
+ # a default plugin which is linked regardless of whether MockPlugins2 is linked.
+ # It's possible the qmake behavior is also wrong, because the qmake qt5 test seems to
+ # expect to link the plugin if both MockPlugins1 AND MockPlugins2 are linked, but qt.pf
+ # suggests that MockPlugins1 OR MockPlugins2 is sufficient to link the plugin, not both.
+ # See QTBUG-93501
+ QMock3Plugin
+)
+target_link_libraries(default_link PRIVATE Qt6::MockPlugins2)
create_test_executable(manual QMock1Plugin QMock2Plugin QMock3Plugin QMock4Plugin)
-qt5_import_plugins(manual
- INCLUDE Qt5::QMock3Plugin Qt5::QMock4Plugin
+qt_import_plugins(manual
+ INCLUDE Qt6::QMock3Plugin Qt6::QMock4Plugin
)
create_test_executable(manual_genex QMock1Plugin QMock2Plugin QMock3Plugin)
-qt5_import_plugins(manual_genex
- INCLUDE $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
+qt_import_plugins(manual_genex
+ INCLUDE $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock4Plugin>
)
create_test_executable(blacklist QMock1Plugin)
-qt5_import_plugins(blacklist
- EXCLUDE Qt5::QMock2Plugin Qt5::QMock3Plugin
+qt_import_plugins(blacklist
+ EXCLUDE Qt6::QMock2Plugin Qt6::QMock3Plugin
)
create_test_executable(blacklist_genex QMock1Plugin)
-qt5_import_plugins(blacklist_genex
- EXCLUDE $<1:Qt5::QMock2Plugin> $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock1Plugin>
+qt_import_plugins(blacklist_genex
+ EXCLUDE $<1:Qt6::QMock2Plugin> $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock1Plugin>
)
create_test_executable(override QMock3Plugin QMock4Plugin)
-qt5_import_plugins(override
- INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin Qt5::QMock4Plugin
+qt_import_plugins(override
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock3Plugin Qt6::QMock4Plugin
)
create_test_executable(override_genex QMock3Plugin)
-qt5_import_plugins(override_genex
- INCLUDE_BY_TYPE mockplugin $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
+qt_import_plugins(override_genex
+ INCLUDE_BY_TYPE mockplugin $<1:Qt6::QMock3Plugin> $<0:Qt6::QMock4Plugin>
)
+get_target_property(prop_plugs override_genex QT_PLUGINS)
+get_target_property(prop_types override_genex QT_PLUGINS_mockplugin)
create_test_executable(override_mix QMock2Plugin QMock3Plugin)
-qt5_import_plugins(override_mix
- INCLUDE Qt5::QMock2Plugin
- INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin
+qt_import_plugins(override_mix
+ INCLUDE Qt6::QMock2Plugin
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock3Plugin
)
if(NOT WIN32)
# Compiling an empty static array fails on Windows.
create_test_executable(none)
- qt5_import_plugins(none
+ qt_import_plugins(none
EXCLUDE_BY_TYPE mockplugin
)
endif()
create_test_executable(none_mix QMock3Plugin QMock4Plugin)
-qt5_import_plugins(none_mix
- INCLUDE Qt5::QMock3Plugin Qt5::QMock4Plugin
+qt_import_plugins(none_mix
+ INCLUDE Qt6::QMock3Plugin Qt6::QMock4Plugin
EXCLUDE_BY_TYPE mockplugin
)
+# QMock5Plugin links against the Qt::MockPlugins3 module, which provides the default plugin
+# QMock6Plugin which is why it is pulled in.
create_test_executable(recursive QMock5Plugin QMock6Plugin)
-qt5_import_plugins(recursive
- INCLUDE_BY_TYPE mockplugin Qt5::QMock5Plugin
+qt_import_plugins(recursive
+ INCLUDE_BY_TYPE mockplugin Qt6::QMock5Plugin
)