qt5base-lts/cmake/QtModuleConfig.cmake.in
Alexandru Croitor 1fc70ac0de 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>
2019-07-30 13:26:37 +00:00

43 lines
1.5 KiB
CMake

@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
# Extra cmake code begin
@extra_cmake_code@
# Extra cmake code end
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
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")
endif()
foreach(extra_cmake_include @extra_cmake_includes@)
include("${CMAKE_CURRENT_LIST_DIR}/${extra_cmake_include}")
endforeach()
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"
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@")