diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-06-03 11:06:07 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-06-03 09:40:14 +0000 |
commit | 4c31ce68d5367a6ec4dd3cf2f55e4b226add876d (patch) | |
tree | db192fbd4c61f154fbaa615217fe9d8caffec3f5 /cmake/QtBuild.cmake | |
parent | 3966ab8e9f601a9315f19eea1bf24628664d79d9 (diff) |
Improve finding of sqlite with vcpkg
We use
qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3)
which intends to find cmake's FindSQLite3.cmake and expects the
existence of the corresponding target. However qt_find_package first
tries to call find_package in config mode, which does not interact well
with vcpkg's sqlite, where sqlite3-config.cmake is provided to support
multi-config targets. So that call will appear to succeed, yet the
expected targets are not there of course.
Therefore this patch adds a sanity check for the target existence and
allows for a fallback to the module mode for find_package, in order to
find CMake's FindSQLite3.cmake.
Change-Id: I660f26c38369c3504df1c590e9d3a51ff1f65c6c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 0db99d07f1..fd9cc09572 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1901,6 +1901,24 @@ macro(qt_find_package) set(config_package_arg ${arg_UNPARSED_ARGUMENTS}) list(APPEND config_package_arg "CONFIG;QUIET") find_package(${config_package_arg}) + + # Double check that in config mode the targets become visible. Sometimes + # only the module mode creates the targets. For example with vcpkg, the sqlite + # package provides sqlite3-config.cmake, which offers multi-config targets but + # in their own way. CMake has FindSQLite3.cmake and with the original + # qt_find_package(SQLite3) call it is our intention to use the cmake package + # in module mode. + if (${ARGV0}_FOUND AND arg_PROVIDED_TARGETS) + foreach(expected_target ${arg_PROVIDED_TARGETS}) + if (TARGET ${expected_target}) + set(any_target_found TRUE) + break() + endif() + endforeach() + if(NOT any_target_found) + set(${ARGV0}_FOUND) + endif() + endif() endif() # Ensure the options are back in the original unparsed arguments |