qt5base-lts/cmake/QtPluginDependencies.cmake.in
Alexandru Croitor 7119023829 Always try to find dependencies for plugins
Generated plugin CMake files should always try to call
find_dependency, especially in static builds.

pkg_check_modules sets a cache value for foo_FOUND instead of
a directory scope foo_FOUND, which means that find_dependency
will not be called in another scope, and thus fail to create
needed imported targets.

Note this makes the code be the same as in
ModuleDependencies.cmake.in.

Change-Id: I0b58b038afcb72cb27d0b433371bc9cb5e4bfec9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-14 15:02:52 +00:00

43 lines
1.2 KiB
CMake

# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
set(_third_party_deps "@third_party_deps@")
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
list(GET _target_dep 2 components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
find_dependency(${find_package_args} COMPONENTS ${components})
else()
find_dependency(${find_package_args})
endif()
if (NOT ${pkg}_FOUND)
set(@target@_FOUND FALSE)
return()
endif()
endforeach()
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(_target_deps "@target_deps@")
foreach(_target_dep ${_target_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
if (NOT ${pkg}_FOUND)
find_dependency(${pkg} ${version}
PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
)
endif()
if (NOT ${pkg}_FOUND)
set(@target@_FOUND FALSE)
return()
endif()
endforeach()