From 1fc70ac0dedc610107a46cef55fedd6dc519f00b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 30 Jul 2019 12:48:12 +0200 Subject: Fix creation of generated plugin cpp files in static builds When building qtdeclarative against a static iOS qtbase build, QtNetwork is find_package'd twice, once in the top level CMakeLists.txt file, and once by the qtuiotouchplugin which has Network as a dependency. This meant that the static plugins that Network exposes had auto import cpp files generated twice, which failed the configuration of qtdeclarative. To fix this, don't generate the same file more than once. To do that, protect the inclusion of the FooPlugins.cmake file, to only be included once in every directory scope. That can be achieved by setting a variable to TRUE when the target does not exist yet. If the target exists in the same scope, that means that find_package() was called a second time in the same scope, so there is no need to include the Plugins file. Change-Id: I9d7c3e7b7c22c2b4526cf1d717b9d15919f213f3 Reviewed-by: Leander Beernaert Reviewed-by: Simon Hausmann --- cmake/QtModuleConfig.cmake.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 4bbd485fc4..2f042e6b2c 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -14,6 +14,11 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependenci include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake") endif() +# Guard against multiple inclusion of the plugins file in the same local directory scope. +if(NOT TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@) + set(_QT_NEED_TO_INCLUDE_PLUGINS_@target@ TRUE) +endif() + if (NOT QT_NO_CREATE_TARGETS) include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake") @@ -28,8 +33,10 @@ include(${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/QtFeature.cmake) qt_make_features_available(@QT_CMAKE_EXPORT_NAMESPACE@::@target@) set("@INSTALL_CMAKE_NAMESPACE@@target@_FOUND" TRUE) -if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake") +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake" + AND _QT_NEED_TO_INCLUDE_PLUGINS_@target@) include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake") endif() +unset(_QT_NEED_TO_INCLUDE_PLUGINS_@target@) list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@") -- cgit v1.2.3