summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-07-30 12:48:12 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-07-30 13:26:37 +0000
commit1fc70ac0dedc610107a46cef55fedd6dc519f00b (patch)
tree3069010c04e4afaaf0527c9874e0f158d19cb5e8
parent5528bcf99c79d7a2658b3444205e003fb36f1283 (diff)
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 <leander.beernaert@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--cmake/QtModuleConfig.cmake.in9
1 files changed, 8 insertions, 1 deletions
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@")