CMake: Add support for auto-importing plugins in CMake

This commit adds transitive dependencies to the plugins, so that a
sane set of default plugins get auto-imported when linking against a
module. It also provides a new function, qt5_import_plugins(), which
allows you to override the set of plugins that get imported. The decision
of whether or not to import a specific plugin is based on several custom
target properties and a very clever generator expression.

Note that this change only imports plugins on static Qt builds. It
does nothing on shared Qt builds, as the shared libraries already have
their own plugin import mechanism.

[ChangeLog][CMake] Added ability to auto-import non-qml plugins on
CMake builds

Task-number: QTBUG-38913
Task-number: QTBUG-76562
Change-Id: I2d6c8908b521cf6ba1ebbbc33a87cb7ddd9935cf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Kyle Edwards 2018-10-17 16:03:28 -04:00 committed by Alexandru Croitor
parent ef74730a59
commit 63d9cd17d0
44 changed files with 1308 additions and 33 deletions

View File

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

View File

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

View File

@ -0,0 +1,2 @@
#include <QtPlugin>
Q_IMPORT_PLUGIN($$CMAKE_PLUGIN_NAME)

View File

@ -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)
!!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}\")
_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\")

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,9 @@
TARGET = mock1plugin
HEADERS += qmock1plugin.h
SOURCES += qmock1plugin.cpp
QT = mockplugins1
PLUGIN_TYPE = mockplugin
PLUGIN_CLASS_NAME = QMock1Plugin
load(qt_plugin)

View File

@ -0,0 +1,10 @@
#include "qmock1plugin.h"
QT_BEGIN_NAMESPACE
QString QMock1Plugin::pluginName() const
{
return "QMock1Plugin";
}
QT_END_NAMESPACE

View File

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

View File

@ -0,0 +1 @@
{}

View File

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

View File

@ -0,0 +1,10 @@
#include "qmock2plugin.h"
QT_BEGIN_NAMESPACE
QString QMock2Plugin::pluginName() const
{
return "QMock2Plugin";
}
QT_END_NAMESPACE

View File

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

View File

@ -0,0 +1 @@
{}

View File

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

View File

@ -0,0 +1,10 @@
#include "qmock3plugin.h"
QT_BEGIN_NAMESPACE
QString QMock3Plugin::pluginName() const
{
return "QMock3Plugin";
}
QT_END_NAMESPACE

View File

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

View File

@ -0,0 +1 @@
{}

View File

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

View File

@ -0,0 +1,10 @@
#include "qmock4plugin.h"
QT_BEGIN_NAMESPACE
QString QMock4Plugin::pluginName() const
{
return "QMock4Plugin";
}
QT_END_NAMESPACE

View File

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

View File

@ -0,0 +1 @@
{}

View File

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

View File

@ -0,0 +1,10 @@
#include "qmock5plugin.h"
QT_BEGIN_NAMESPACE
QString QMock5Plugin::pluginName() const
{
return "QMock5Plugin";
}
QT_END_NAMESPACE

View File

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

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,9 @@
TARGET = mock6plugin
HEADERS += qmock6plugin.h
SOURCES += qmock6plugin.cpp
QT = mockplugins3
PLUGIN_TYPE = mockauxplugin
PLUGIN_CLASS_NAME = QMock6Plugin
load(qt_plugin)

View File

@ -0,0 +1,10 @@
#include "qmock6plugin.h"
QT_BEGIN_NAMESPACE
QString QMock6Plugin::pluginName() const
{
return "QMock6Plugin";
}
QT_END_NAMESPACE

View File

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

View File

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

View File

@ -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() {
}

View File

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

View File

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

View File

@ -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() {
}

View File

@ -0,0 +1,4 @@
TARGET = QtMockPlugins2
QT = core
SOURCES += fake.cpp # Needed to make libtool / ar happy on macOS
load(qt_module)

View File

@ -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() {
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,8 @@
#include <QString>
#include <cstddef>
QString expectedPlugins[] = {
@EXPECTED_PLUGINS@
};
std::size_t numExpectedPlugins = sizeof(expectedPlugins) / sizeof(numExpectedPlugins);

View File

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