CMake: Also import Qt plugins that are not literally named *Plugin

There are some plugins in qtlocation, qtdeclarative whose names are not
suffixed with 'Plugin', so the current logic fails to load the
corresponding QtModule_XXX.cmake file.

Work around this by just searching for

  Qt5$${CMAKE_MODULE_NAME}}_*.cmake.

Users can define QT5_STRICT_PLUGIN_GLOB
or Qt5$${CMAKE_MODULE_NAME}_STRICT_PLUGIN_GLOB
to change back to the old behavior.

[ChangeLog][cmake] Fixed an issue where some Qt location and
declarative plugins whose name did not end with "Plugin"
where not imported by the corresponding Qt component package.

You can force the old behavior by setting QT5_STRICT_PLUGIN_GLOB or
Qt5ModuleName_STRICT_PLUGIN_GLOB before the find_package(Qt5 ...)
call.

Fixes: QTBUG-58812
Change-Id: Ic8adf9562841ed49eabc4f7fb2b5ae257ca606cd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Kai Koehne 2020-02-25 14:18:56 +01:00
parent 6a972f44f3
commit 99ace38d22

View File

@ -566,8 +566,13 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
!!ENDIF // TEMPLATE != aux
!!IF isEmpty(CMAKE_INTERNAL_MODULE)
file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")
# In Qt 5.15 the glob pattern was relaxed to also catch plugins not literally named "Plugin".
# Define QT5_STRICT_PLUGIN_GLOB or ModuleName_STRICT_PLUGIN_GLOB to revert to old behavior.
if (QT5_STRICT_PLUGIN_GLOB OR Qt5$${CMAKE_MODULE_NAME}_STRICT_PLUGIN_GLOB)
file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*Plugin.cmake\")
else()
file(GLOB pluginTargets \"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}_*.cmake\")
endif()
macro(_populate_$${CMAKE_MODULE_NAME}_plugin_properties Plugin Configuration PLUGIN_LOCATION
IsDebugAndRelease)