summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mkspecs/features/create_cmake.prf94
-rw-r--r--mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in35
-rw-r--r--mkspecs/features/data/cmake/Qt5ImportPlugin.cpp.in2
-rw-r--r--mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in95
-rw-r--r--src/corelib/Qt5CoreMacros.cmake32
-rw-r--r--sync.profile3
-rw-r--r--tests/auto/cmake/CMakeLists.txt2
-rw-r--r--tests/auto/cmake/cmake.pro7
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.pro9
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.pro10
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.pro10
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.pro10
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.pro10
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.json1
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.pro9
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp10
-rw-r--r--tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h70
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins.pro36
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/fake.cpp34
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/mockplugins1.pro10
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h72
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins2/fake.cpp34
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins2/mockplugins2.pro4
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/fake.cpp34
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/mockplugins3.pro11
-rw-r--r--tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h72
-rw-r--r--tests/auto/cmake/test_import_plugins/CMakeLists.txt111
-rw-r--r--tests/auto/cmake/test_import_plugins/check.cpp.in8
-rw-r--r--tests/auto/cmake/test_import_plugins/main.cpp101
44 files changed, 1308 insertions, 33 deletions
diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf
index 376a7ded5d..e88d6175a4 100644
--- a/mkspecs/features/create_cmake.prf
+++ b/mkspecs/features/create_cmake.prf
@@ -160,60 +160,95 @@ debug_and_release {
}
contains(CONFIG, plugin) {
- !isEmpty(PLUGIN_EXTENDS):!equals(PLUGIN_EXTENDS, -) {
- count(PLUGIN_EXTENDS, 1, greaterThan): \
- error("Plugin declares to extend multiple modules. We don't handle that ...")
- PLUGIN_MODULE_NAME = $$PLUGIN_EXTENDS
+ equals(PLUGIN_EXTENDS, -) {
+ CMAKE_PLUGIN_EXTENDS = -
} else {
- PLUGIN_MODULE_NAME =
- for (mod, QT_MODULES) {
- contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
- !isEmpty(PLUGIN_MODULE_NAME): \
- error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
- PLUGIN_MODULE_NAME = $$mod
- break()
- }
+ list_plugin_extends =
+ for (p, PLUGIN_EXTENDS) {
+ m = $$cmakeModuleName($$p)
+ list_plugin_extends += Qt5::$$m
}
- isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
+ CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
}
+ PLUGIN_MODULE_NAME =
+ unique_qt_modules = $$unique(QT_MODULES) # In case modules appear in multiple places
+ for (mod, unique_qt_modules) {
+ contains(QT.$${mod}.plugin_types, $$PLUGIN_TYPE) {
+ !isEmpty(PLUGIN_MODULE_NAME): \
+ error("Multiple modules claim plugin type '$$PLUGIN_TYPE' ($$mod, in addition to $$PLUGIN_MODULE_NAME)")
+ PLUGIN_MODULE_NAME = $$mod
+ }
+ }
+ isEmpty(PLUGIN_MODULE_NAME): error("No module claims plugin type '$$PLUGIN_TYPE'")
+
+ sorted_deps = $$sort_depends(QT_PLUGIN.$${CMAKE_QT_STEM}.DEPENDS, QT.)
+ mod_deps =
+ lib_deps =
+ aux_mod_deps =
+ aux_lib_deps =
+ for (dep, sorted_deps) {
+ cdep = $$cmakeModuleName($$dep)
+ mod_deps += $$cdep
+ lib_deps += Qt5::$$cdep
+ }
+ CMAKE_PLUGIN_MODULE_DEPS = $$join(mod_deps, ";")
+ CMAKE_PLUGIN_QT5_MODULE_DEPS = $$join(lib_deps, ";")
+
CMAKE_MODULE_NAME = $$cmakeModuleName($$PLUGIN_MODULE_NAME)
CMAKE_PLUGIN_NAME = $$PLUGIN_CLASS_NAME
+ CMAKE_PLUGIN_TYPE = $$PLUGIN_TYPE
+ CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _)
win32 {
isEmpty(CMAKE_STATIC_TYPE) {
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.dll
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.dll
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.dll
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
} else:mingw {
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}.a
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}d.a
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.a
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.prl
} else { # MSVC static
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${TARGET}.lib
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${TARGET}d.lib
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.lib
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
}
} else {
mac {
- isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .dylib
- else: CMAKE_PlUGIN_EXT = .a
+ isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .dylib
+ else: CMAKE_PLUGIN_EXT = .a
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug$${CMAKE_PLUGIN_EXT}
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}_debug.prl
} else {
- isEmpty(CMAKE_STATIC_TYPE): CMAKE_PlUGIN_EXT = .so
- else: CMAKE_PlUGIN_EXT = .a
+ isEmpty(CMAKE_STATIC_TYPE): CMAKE_PLUGIN_EXT = .so
+ else: CMAKE_PLUGIN_EXT = .a
- CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
- CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${TARGET}$${CMAKE_PlUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}$${CMAKE_PLUGIN_EXT}
+ CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
+ CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
}
}
cmake_target_file.input = $$PWD/data/cmake/Qt5PluginTarget.cmake.in
cmake_target_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}.cmake
+ cmake_qt5_plugin_import_file.input = $$PWD/data/cmake/Qt5ImportPlugin.cpp.in
+ cmake_qt5_plugin_import_file.output = $$CMAKE_OUT_DIR/Qt5$${CMAKE_MODULE_NAME}/Qt5$${CMAKE_MODULE_NAME}_$${PLUGIN_CLASS_NAME}_Import.cpp
- !build_pass:QMAKE_SUBSTITUTES += \
- cmake_target_file
+ !build_pass {
+ QMAKE_SUBSTITUTES += cmake_target_file
+ static|staticlib: QMAKE_SUBSTITUTES += cmake_qt5_plugin_import_file
+ }
cmake_qt5_plugin_file.files = $$cmake_target_file.output
+ static|staticlib: cmake_qt5_plugin_file.files += $$cmake_qt5_plugin_import_file.output
cmake_qt5_plugin_file.path = $$[QT_INSTALL_LIBS]/cmake/Qt5$${CMAKE_MODULE_NAME}
INSTALLS += cmake_qt5_plugin_file
@@ -244,6 +279,7 @@ CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
+CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
mac {
!isEmpty(CMAKE_STATIC_TYPE) {
diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
index 2b7c1d28c4..7a599d30d5 100644
--- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -397,6 +397,8 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";"))
+ set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\")
+
set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
foreach (_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR ${Qt5$${CMAKE_MODULE_NAME}_OWN_PRIVATE_INCLUDE_DIRS})
if (NOT EXISTS ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIR})
@@ -504,7 +506,8 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")
- macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION)
+ macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION
+ IsDebugAndRelease)
set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
!!IF isEmpty(CMAKE_PLUGIN_DIR_IS_ABSOLUTE)
@@ -516,6 +519,36 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_target_properties(Qt5::${Plugin} PROPERTIES
\"IMPORTED_LOCATION_${Configuration}\" ${imported_location}
)
+
+!!IF !isEmpty(CMAKE_STATIC_TYPE)
+ set(_static_deps
+ ${_Qt5${Plugin}_STATIC_${Configuration}_LIB_DEPENDENCIES}
+ )
+
+ if(NOT "${IsDebugAndRelease}")
+ set(_genex_condition \"1\")
+ else()
+ if("${Configuration}" STREQUAL "DEBUG")
+ set(_genex_condition \"$<CONFIG:Debug>\")
+ else()
+ set(_genex_condition \"$<NOT:$<CONFIG:Debug>>\")
+ endif()
+ endif()
+ if(_static_deps)
+ set(_static_deps_genex \"$<${_genex_condition}:${_static_deps}>\")
+ set_property(TARGET Qt5::${Plugin} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ \"${_static_deps_genex}\"
+ )
+ endif()
+
+ set(_static_link_flags \"${_Qt5${Plugin}_STATIC_${Configuration}_LINK_FLAGS}\")
+ if(NOT CMAKE_VERSION VERSION_LESS \"3.13\" AND _static_link_flags)
+ set(_static_link_flags_genex \"$<${_genex_condition}:${_static_link_flags}>\")
+ set_property(TARGET Qt5::${Plugin} APPEND PROPERTY INTERFACE_LINK_OPTIONS
+ \"${_static_link_flags_genex}\"
+ )
+ endif()
+!!ENDIF
endmacro()
if (pluginTargets)
diff --git a/mkspecs/features/data/cmake/Qt5ImportPlugin.cpp.in b/mkspecs/features/data/cmake/Qt5ImportPlugin.cpp.in
new file mode 100644
index 0000000000..6e27f7a260
--- /dev/null
+++ b/mkspecs/features/data/cmake/Qt5ImportPlugin.cpp.in
@@ -0,0 +1,2 @@
+#include <QtPlugin>
+Q_IMPORT_PLUGIN($$CMAKE_PLUGIN_NAME)
diff --git a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
index 5baf0fdb10..7b70cfed09 100644
--- a/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
+++ b/mkspecs/features/data/cmake/Qt5PluginTarget.cmake.in
@@ -1,11 +1,102 @@
add_library(Qt5::$$CMAKE_PLUGIN_NAME MODULE IMPORTED)
+!!IF !isEmpty(CMAKE_STATIC_TYPE)
+set(_Qt5$${CMAKE_PLUGIN_NAME}_MODULE_DEPENDENCIES \"$${CMAKE_PLUGIN_MODULE_DEPS}\")
+
+foreach(_module_dep ${_Qt5$${CMAKE_PLUGIN_NAME}_MODULE_DEPENDENCIES})
+ if(NOT Qt5${_module_dep}_FOUND)
+ find_package(Qt5${_module_dep}
+ $$VERSION ${_Qt5$${CMAKE_MODULE_NAME}_FIND_VERSION_EXACT}
+ ${_Qt5$${CMAKE_MODULE_NAME}_DEPENDENCIES_FIND_QUIET}
+ ${_Qt5$${CMAKE_MODULE_NAME}_FIND_DEPENDENCIES_REQUIRED}
+ PATHS \"${CMAKE_CURRENT_LIST_DIR}/..\" NO_DEFAULT_PATH
+ )
+ endif()
+endforeach()
+
!!IF !isEmpty(CMAKE_RELEASE_TYPE)
-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\")
+!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LIB_DEPENDENCIES
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LINK_FLAGS
+)
+!!ELSE
+_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
+ \"$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LIB_DEPENDENCIES
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_RELEASE_LINK_FLAGS
+)
!!ENDIF
+!!ENDIF
+
!!IF !isEmpty(CMAKE_DEBUG_TYPE)
-_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\")
+!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
+ \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LIB_DEPENDENCIES
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LINK_FLAGS
+)
+!!ELSE
+_qt5_$${CMAKE_MODULE_NAME}_process_prl_file(
+ \"$${CMAKE_PLUGIN_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LIB_DEPENDENCIES
+ _Qt5$${CMAKE_PLUGIN_NAME}_STATIC_DEBUG_LINK_FLAGS
+)
+!!ENDIF
+!!ENDIF
+
+set_property(TARGET Qt5::$$CMAKE_PLUGIN_NAME PROPERTY INTERFACE_SOURCES
+ \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_$${CMAKE_PLUGIN_NAME}_Import.cpp\"
+)
+!!ENDIF
+
+!!IF !isEmpty(CMAKE_RELEASE_TYPE)
+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME RELEASE \"$${CMAKE_PLUGIN_LOCATION_RELEASE}\" $${CMAKE_DEBUG_AND_RELEASE})
+!!ENDIF
+!!IF !isEmpty(CMAKE_DEBUG_TYPE)
+_populate_$${CMAKE_MODULE_NAME}_plugin_properties($$CMAKE_PLUGIN_NAME DEBUG \"$${CMAKE_PLUGIN_LOCATION_DEBUG}\" $${CMAKE_DEBUG_AND_RELEASE})
!!ENDIF
list(APPEND Qt5$${CMAKE_MODULE_NAME}_PLUGINS Qt5::$$CMAKE_PLUGIN_NAME)
+set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY QT_ALL_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED} Qt5::$${CMAKE_PLUGIN_NAME})
+!!IF !isEmpty(CMAKE_STATIC_TYPE)
+# $<GENEX_EVAL:...> wasn\'t added until CMake 3.12, so put a version guard around it
+if(CMAKE_VERSION VERSION_LESS \"3.12\")
+ set(_manual_plugins_genex \"$<TARGET_PROPERTY:QT_PLUGINS>\")
+ set(_plugin_type_genex \"$<TARGET_PROPERTY:QT_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED}>\")
+ set(_no_plugins_genex \"$<TARGET_PROPERTY:QT_NO_PLUGINS>\")
+else()
+ set(_manual_plugins_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>\")
+ set(_plugin_type_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS_$${CMAKE_PLUGIN_TYPE_ESCAPED}>>\")
+ set(_no_plugins_genex \"$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>\")
+endif()
+set(_user_specified_genex
+ \"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
+)
+string(CONCAT _plugin_genex
+ \"$<$<OR:\"
+ # Add this plugin if it\'s in the list of manual plugins or plugins for the type
+ \"${_user_specified_genex},\"
+ # Add this plugin if the list of plugins for the type is empty, the PLUGIN_EXTENDS
+ # is either empty or equal to the module name, and the user hasn\'t blacklisted it
+ \"$<AND:\"
+ \"$<STREQUAL:${_plugin_type_genex},>,\"
+ \"$<OR:\"
+ \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt5::$${CMAKE_MODULE_NAME}>,\"
+ \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\"
+ \">,\"
+ \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
+ \">\"
+ \">:Qt5::$$CMAKE_PLUGIN_NAME>\"
+)
+set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ ${_plugin_genex}
+)
+set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ \"$${CMAKE_PLUGIN_QT5_MODULE_DEPS}\"
+)
+!!ENDIF
+set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\")
+set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\")
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 0f006fe1e3..17cc19fc4e 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -393,3 +393,35 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
endforeach()
endmacro()
endif()
+
+function(QT5_IMPORT_PLUGINS TARGET_NAME)
+ set(_doing "")
+ foreach(_arg ${ARGN})
+ if(_arg STREQUAL "INCLUDE")
+ set(_doing "INCLUDE")
+ elseif(_arg STREQUAL "EXCLUDE")
+ set(_doing "EXCLUDE")
+ elseif(_arg STREQUAL "INCLUDE_BY_TYPE")
+ set(_doing "INCLUDE_BY_TYPE")
+ elseif(_arg STREQUAL "EXCLUDE_BY_TYPE")
+ set(_doing "EXCLUDE_BY_TYPE")
+ else()
+ if(_doing STREQUAL "INCLUDE")
+ set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_PLUGINS "${_arg}")
+ elseif(_doing STREQUAL "EXCLUDE")
+ set_property(TARGET ${TARGET_NAME} APPEND PROPERTY QT_NO_PLUGINS "${_arg}")
+ elseif(_doing STREQUAL "INCLUDE_BY_TYPE")
+ string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
+ set(_doing "INCLUDE_BY_TYPE_PLUGINS")
+ elseif(_doing STREQUAL "INCLUDE_BY_TYPE_PLUGINS")
+ set_property(TARGET ${TARGET_NAME} APPEND PROPERTY "QT_PLUGINS_${_plugin_type}" "${_arg}")
+ elseif(_doing STREQUAL "EXCLUDE_BY_TYPE")
+ string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
+ set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -)
+ set(_doing "")
+ else()
+ message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"")
+ endif()
+ endif()
+ endforeach()
+endfunction()
diff --git a/sync.profile b/sync.profile
index e6fc285573..fd44197a00 100644
--- a/sync.profile
+++ b/sync.profile
@@ -37,6 +37,9 @@
"QtZlib" => "!>$basedir/src/corelib;$basedir/src/3rdparty/zlib",
"QtOpenGLExtensions" => "$basedir/src/openglextensions",
"QtEglFSDeviceIntegration" => "$basedir/src/plugins/platforms/eglfs",
+ "QtMockPlugins1" => "$basedir/tests/auto/cmake/mockplugins/mockplugins1",
+ "QtMockPlugins2" => "$basedir/tests/auto/cmake/mockplugins/mockplugins2",
+ "QtMockPlugins3" => "$basedir/tests/auto/cmake/mockplugins/mockplugins3",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
"QtEglFSDeviceIntegration" => "api",
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt
index 5b10a74d3f..ed900f7805 100644
--- a/tests/auto/cmake/CMakeLists.txt
+++ b/tests/auto/cmake/CMakeLists.txt
@@ -160,3 +160,5 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8)
# Reason: SKIP_* properties were added in CMake 3.8 only
expect_pass(test_QTBUG-63422)
endif()
+
+expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND})
diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
index 9c715974f8..06509f4ad3 100644
--- a/tests/auto/cmake/cmake.pro
+++ b/tests/auto/cmake/cmake.pro
@@ -1,7 +1,12 @@
-# Cause make to do nothing.
TEMPLATE = subdirs
+# installed_cmake includes this file, and tries to add the mockplugins
+# directory relative to itself, but doesn't have its own copy of the directory.
+# So, we make the path absolute so it includes this copy of the directory
+# instead.
+SUBDIRS += $$PWD/mockplugins
+
CMAKE_QT_MODULES_UNDER_TEST = core network xml sql testlib
qtHaveModule(dbus): CMAKE_QT_MODULES_UNDER_TEST += dbus
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.json b/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.pro b/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.pro
new file mode 100644
index 0000000000..1ccbe924ae
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock1plugin/mock1plugin.pro
@@ -0,0 +1,9 @@
+TARGET = mock1plugin
+
+HEADERS += qmock1plugin.h
+SOURCES += qmock1plugin.cpp
+QT = mockplugins1
+
+PLUGIN_TYPE = mockplugin
+PLUGIN_CLASS_NAME = QMock1Plugin
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp
new file mode 100644
index 0000000000..2ee817d80a
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock1plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock1Plugin::pluginName() const
+{
+ return "QMock1Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
new file mode 100644
index 0000000000..e2e114b1d9
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock1plugin/qmock1plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK1PLUGIN_H
+#define QMOCK1PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins1/QMockPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock1Plugin : public QObject, public QMockPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockPlugin_iid FILE "mock1plugin.json")
+ Q_INTERFACES(QMockPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK1PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.json b/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.pro b/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.pro
new file mode 100644
index 0000000000..75dc21cf0a
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock2plugin/mock2plugin.pro
@@ -0,0 +1,10 @@
+TARGET = mock2plugin
+
+HEADERS += qmock2plugin.h
+SOURCES += qmock2plugin.cpp
+QT = mockplugins1
+
+PLUGIN_TYPE = mockplugin
+PLUGIN_CLASS_NAME = QMock2Plugin
+PLUGIN_EXTENDS = mockplugins1
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp
new file mode 100644
index 0000000000..5b3280e884
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock2plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock2Plugin::pluginName() const
+{
+ return "QMock2Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
new file mode 100644
index 0000000000..be99133dc8
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock2plugin/qmock2plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK2PLUGIN_H
+#define QMOCK2PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins1/QMockPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock2Plugin : public QObject, public QMockPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockPlugin_iid FILE "mock2plugin.json")
+ Q_INTERFACES(QMockPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK2PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.json b/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.pro b/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.pro
new file mode 100644
index 0000000000..ed7df603bb
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock3plugin/mock3plugin.pro
@@ -0,0 +1,10 @@
+TARGET = mock3plugin
+
+HEADERS += qmock3plugin.h
+SOURCES += qmock3plugin.cpp
+QT = mockplugins1
+
+PLUGIN_TYPE = mockplugin
+PLUGIN_CLASS_NAME = QMock3Plugin
+PLUGIN_EXTENDS = mockplugins1 mockplugins2
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp
new file mode 100644
index 0000000000..b38f854e4b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock3plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock3Plugin::pluginName() const
+{
+ return "QMock3Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
new file mode 100644
index 0000000000..08d1aa68ce
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock3plugin/qmock3plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK3PLUGIN_H
+#define QMOCK3PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins1/QMockPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock3Plugin : public QObject, public QMockPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockPlugin_iid FILE "mock3plugin.json")
+ Q_INTERFACES(QMockPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK3PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.json b/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.pro b/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.pro
new file mode 100644
index 0000000000..4dd2d6c547
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock4plugin/mock4plugin.pro
@@ -0,0 +1,10 @@
+TARGET = mock4plugin
+
+HEADERS += qmock4plugin.h
+SOURCES += qmock4plugin.cpp
+QT = mockplugins1
+
+PLUGIN_TYPE = mockplugin
+PLUGIN_CLASS_NAME = QMock4Plugin
+PLUGIN_EXTENDS = -
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp
new file mode 100644
index 0000000000..5deaf7f43f
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock4plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock4Plugin::pluginName() const
+{
+ return "QMock4Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
new file mode 100644
index 0000000000..0776bef002
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock4plugin/qmock4plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK4PLUGIN_H
+#define QMOCK4PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins1/QMockPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock4Plugin : public QObject, public QMockPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockPlugin_iid FILE "mock4plugin.json")
+ Q_INTERFACES(QMockPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK4PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.json b/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.pro b/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.pro
new file mode 100644
index 0000000000..29496868fe
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock5plugin/mock5plugin.pro
@@ -0,0 +1,10 @@
+TARGET = mock5plugin
+
+HEADERS += qmock5plugin.h
+SOURCES += qmock5plugin.cpp
+QT = mockplugins3
+
+PLUGIN_TYPE = mockplugin
+PLUGIN_CLASS_NAME = QMock5Plugin
+PLUGIN_EXTENDS = -
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp
new file mode 100644
index 0000000000..c5b4620516
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock5plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock5Plugin::pluginName() const
+{
+ return "QMock5Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
new file mode 100644
index 0000000000..2f387da203
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock5plugin/qmock5plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK5PLUGIN_H
+#define QMOCK5PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins1/QMockPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock5Plugin : public QObject, public QMockPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockPlugin_iid FILE "mock5plugin.json")
+ Q_INTERFACES(QMockPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK5PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.json b/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.pro b/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.pro
new file mode 100644
index 0000000000..140f198811
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock6plugin/mock6plugin.pro
@@ -0,0 +1,9 @@
+TARGET = mock6plugin
+
+HEADERS += qmock6plugin.h
+SOURCES += qmock6plugin.cpp
+QT = mockplugins3
+
+PLUGIN_TYPE = mockauxplugin
+PLUGIN_CLASS_NAME = QMock6Plugin
+load(qt_plugin)
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp
new file mode 100644
index 0000000000..4a0329c68a
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.cpp
@@ -0,0 +1,10 @@
+#include "qmock6plugin.h"
+
+QT_BEGIN_NAMESPACE
+
+QString QMock6Plugin::pluginName() const
+{
+ return "QMock6Plugin";
+}
+
+QT_END_NAMESPACE
diff --git a/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
new file mode 100644
index 0000000000..6b29b6703b
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mock6plugin/qmock6plugin.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCK6PLUGIN_H
+#define QMOCK6PLUGIN_H
+
+#include <QObject>
+#include <QtMockPlugins3/QMockAuxPlugin>
+
+QT_BEGIN_NAMESPACE
+
+class QMock6Plugin : public QObject, public QMockAuxPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QMockAuxPlugin_iid FILE "mock6plugin.json")
+ Q_INTERFACES(QMockAuxPlugin)
+public:
+ QString pluginName() const override;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMOCK6PLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mockplugins.pro b/tests/auto/cmake/mockplugins/mockplugins.pro
new file mode 100644
index 0000000000..830d130a05
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins.pro
@@ -0,0 +1,36 @@
+TEMPLATE = subdirs
+
+src_mock1plugin.subdir = $$PWD/mock1plugin
+src_mock1plugin.target = sub-mockplugin1
+src_mock1plugin.depends = mockplugins1
+
+src_mock2plugin.subdir = $$PWD/mock2plugin
+src_mock2plugin.target = sub-mockplugin2
+src_mock2plugin.depends = mockplugins1
+
+src_mock3plugin.subdir = $$PWD/mock3plugin
+src_mock3plugin.target = sub-mockplugin3
+src_mock3plugin.depends = mockplugins1
+
+src_mock4plugin.subdir = $$PWD/mock4plugin
+src_mock4plugin.target = sub-mockplugin4
+src_mock4plugin.depends = mockplugins1
+
+src_mock5plugin.subdir = $$PWD/mock5plugin
+src_mock5plugin.target = sub-mockplugin5
+src_mock5plugin.depends = mockplugins3
+
+src_mock6plugin.subdir = $$PWD/mock6plugin
+src_mock6plugin.target = sub-mockplugin6
+src_mock6plugin.depends = mockplugins3
+
+SUBDIRS += \
+ mockplugins1 \
+ mockplugins2 \
+ mockplugins3 \
+ src_mock1plugin \
+ src_mock2plugin \
+ src_mock3plugin \
+ src_mock4plugin \
+ src_mock5plugin \
+ src_mock6plugin
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
new file mode 100644
index 0000000000..f95eba6055
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins1/fake.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtGlobal>
+
+// Empty exported function needed to create .lib on Windows.
+Q_DECL_EXPORT void mockplugins1_foo() {
+
+}
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/mockplugins1.pro b/tests/auto/cmake/mockplugins/mockplugins1/mockplugins1.pro
new file mode 100644
index 0000000000..dd98937ee3
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins1/mockplugins1.pro
@@ -0,0 +1,10 @@
+TARGET = QtMockPlugins1
+QT = core
+MODULE_PLUGIN_TYPES = mockplugin
+
+# Fake a git_build, to force qmake to run syncqt.pl when doing a standalone tests build
+# like it is done in Coin, otherwise module headers would not be generated.
+CONFIG += git_build
+HEADERS += qmockplugin.h
+SOURCES += fake.cpp # Needed to make libtool / ar happy on macOS
+load(qt_module)
diff --git a/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
new file mode 100644
index 0000000000..9427ae9212
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins1/qmockplugin.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCKPLUGIN_H
+#define QMOCKPLUGIN_H
+
+#include <QString>
+#include <QtPlugin>
+
+QT_BEGIN_NAMESPACE
+
+#define QMockPlugin_iid "org.qt-project.Qt.Tests.QMockPlugin"
+
+class QMockPlugin
+{
+public:
+ virtual ~QMockPlugin() {}
+ virtual QString pluginName() const = 0;
+};
+
+Q_DECLARE_INTERFACE(QMockPlugin, QMockPlugin_iid)
+
+QT_END_NAMESPACE
+
+#endif // QMOCKPLUGIN_H
diff --git a/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
new file mode 100644
index 0000000000..384623d646
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins2/fake.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtGlobal>
+
+// Empty exported function needed to create .lib on Windows.
+Q_DECL_EXPORT void mockplugins2_foo() {
+
+}
diff --git a/tests/auto/cmake/mockplugins/mockplugins2/mockplugins2.pro b/tests/auto/cmake/mockplugins/mockplugins2/mockplugins2.pro
new file mode 100644
index 0000000000..1dd03391e8
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins2/mockplugins2.pro
@@ -0,0 +1,4 @@
+TARGET = QtMockPlugins2
+QT = core
+SOURCES += fake.cpp # Needed to make libtool / ar happy on macOS
+load(qt_module)
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
new file mode 100644
index 0000000000..9ec2b42181
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins3/fake.cpp
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/QtGlobal>
+
+// Empty exported function needed to create .lib on Windows.
+Q_DECL_EXPORT void mockplugins3_foo() {
+
+}
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/mockplugins3.pro b/tests/auto/cmake/mockplugins/mockplugins3/mockplugins3.pro
new file mode 100644
index 0000000000..3651abaafa
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins3/mockplugins3.pro
@@ -0,0 +1,11 @@
+TARGET = QtMockPlugins3
+QT = core
+MODULE_PLUGIN_TYPES = mockauxplugin
+
+# Fake a git_build, to force qmake to run syncqt.pl when doing a standalone tests build
+# like it is done in Coin, otherwise module headers would not be generated.
+CONFIG += git_build
+HEADERS += qmockauxplugin.h
+SOURCES += fake.cpp # Needed to make libtool / ar happy on macOS
+
+load(qt_module)
diff --git a/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
new file mode 100644
index 0000000000..25e4762bac
--- /dev/null
+++ b/tests/auto/cmake/mockplugins/mockplugins3/qmockauxplugin.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOCKAUXPLUGIN_H
+#define QMOCKAUXPLUGIN_H
+
+#include <QString>
+#include <QtPlugin>
+
+QT_BEGIN_NAMESPACE
+
+#define QMockAuxPlugin_iid "org.qt-project.Qt.Tests.QMockAuxPlugin"
+
+class QMockAuxPlugin
+{
+public:
+ virtual ~QMockAuxPlugin() {}
+ virtual QString pluginName() const = 0;
+};
+
+Q_DECLARE_INTERFACE(QMockAuxPlugin, QMockAuxPlugin_iid)
+
+QT_END_NAMESPACE
+
+#endif // QMOCKAUXPLUGIN_H
diff --git a/tests/auto/cmake/test_import_plugins/CMakeLists.txt b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
new file mode 100644
index 0000000000..a793fe211d
--- /dev/null
+++ b/tests/auto/cmake/test_import_plugins/CMakeLists.txt
@@ -0,0 +1,111 @@
+
+cmake_minimum_required(VERSION 3.1)
+
+project(import_plugins_advanced)
+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})
+
+function(create_test_executable TARGET_NAME)
+ set(CHECK_FILE ${CMAKE_BINARY_DIR}/${TARGET_NAME}_check.cpp)
+
+ set(EXPECTED_PLUGINS)
+ foreach(_p ${ARGN})
+ string(APPEND EXPECTED_PLUGINS " \"${_p}\",\n")
+ endforeach()
+ 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)
+ add_test(test_${TARGET_NAME} ${TARGET_NAME})
+endfunction()
+
+create_test_executable(default QMock1Plugin QMock2Plugin)
+# No call to qt5_import_plugins() for the default
+
+# 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
+
+create_test_executable(manual QMock1Plugin QMock2Plugin QMock3Plugin QMock4Plugin)
+qt5_import_plugins(manual
+ INCLUDE Qt5::QMock3Plugin Qt5::QMock4Plugin
+)
+
+create_test_executable(manual_genex QMock1Plugin QMock2Plugin QMock3Plugin)
+qt5_import_plugins(manual_genex
+ INCLUDE $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
+)
+
+create_test_executable(blacklist QMock1Plugin)
+qt5_import_plugins(blacklist
+ EXCLUDE Qt5::QMock2Plugin Qt5::QMock3Plugin
+)
+
+create_test_executable(blacklist_genex QMock1Plugin)
+qt5_import_plugins(blacklist_genex
+ EXCLUDE $<1:Qt5::QMock2Plugin> $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock1Plugin>
+)
+
+create_test_executable(override QMock3Plugin QMock4Plugin)
+qt5_import_plugins(override
+ INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin Qt5::QMock4Plugin
+)
+
+create_test_executable(override_genex QMock3Plugin)
+qt5_import_plugins(override_genex
+ INCLUDE_BY_TYPE mockplugin $<1:Qt5::QMock3Plugin> $<0:Qt5::QMock4Plugin>
+)
+
+create_test_executable(override_mix QMock2Plugin QMock3Plugin)
+qt5_import_plugins(override_mix
+ INCLUDE Qt5::QMock2Plugin
+ INCLUDE_BY_TYPE mockplugin Qt5::QMock3Plugin
+)
+
+if(NOT WIN32)
+ # Compiling an empty static array fails on Windows.
+ create_test_executable(none)
+ qt5_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
+ EXCLUDE_BY_TYPE mockplugin
+)
+
+create_test_executable(recursive QMock5Plugin QMock6Plugin)
+qt5_import_plugins(recursive
+ INCLUDE_BY_TYPE mockplugin Qt5::QMock5Plugin
+)
diff --git a/tests/auto/cmake/test_import_plugins/check.cpp.in b/tests/auto/cmake/test_import_plugins/check.cpp.in
new file mode 100644
index 0000000000..df6ea03d2d
--- /dev/null
+++ b/tests/auto/cmake/test_import_plugins/check.cpp.in
@@ -0,0 +1,8 @@
+#include <QString>
+#include <cstddef>
+
+QString expectedPlugins[] = {
+@EXPECTED_PLUGINS@
+};
+
+std::size_t numExpectedPlugins = sizeof(expectedPlugins) / sizeof(numExpectedPlugins);
diff --git a/tests/auto/cmake/test_import_plugins/main.cpp b/tests/auto/cmake/test_import_plugins/main.cpp
new file mode 100644
index 0000000000..9fcc81754b
--- /dev/null
+++ b/tests/auto/cmake/test_import_plugins/main.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Kitware, Inc.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QPluginLoader>
+#include <QSet>
+#include <QString>
+#include <QVector>
+
+#include <cstddef>
+#include <iostream>
+
+extern QString expectedPlugins[];
+extern std::size_t numExpectedPlugins;
+
+int main(int argc, char **argv)
+{
+#ifdef QT_STATIC
+ QSet<QString> expectedPluginSet;
+ for (std::size_t i = 0; i < numExpectedPlugins; i++) {
+ expectedPluginSet.insert(expectedPlugins[i]);
+ }
+
+ QVector<QStaticPlugin> plugins = QPluginLoader::staticPlugins();
+ QSet<QString> actualPluginSet;
+ for (QStaticPlugin plugin : plugins) {
+ actualPluginSet.insert(plugin.metaData()["className"].toString());
+ }
+
+ if (expectedPluginSet != actualPluginSet) {
+ std::cerr << "Loaded plugins do not match what was expected!" << std::endl
+ << "Expected plugins:" << std::endl;
+
+ QList<QString> expectedPluginList = expectedPluginSet.toList();
+ expectedPluginList.sort();
+ for (QString plugin : expectedPluginList) {
+ std::cerr << (actualPluginSet.contains(plugin) ? " " : "- ")
+ << plugin.toStdString() << std::endl;
+ }
+
+ std::cerr << std::endl << "Actual plugins:" << std::endl;
+
+ QList<QString> actualPluginList = actualPluginSet.toList();
+ actualPluginList.sort();
+ for (QString plugin : actualPluginList) {
+ std::cerr << (expectedPluginSet.contains(plugin) ? " " : "+ ")
+ << plugin.toStdString() << std::endl;
+ }
+
+ return 1;
+ }
+
+#endif
+ return 0;
+}