From dd7e40b1086020f6a054957f4972720cd6849280 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Thu, 23 Apr 2020 08:01:47 +0200 Subject: CMake: qt_find_package() enable debug behavior by default Without this behavior enabled by default it is currently not possible to build QtVirtualKeyboard as a static build. We run into the error where cmake is trying to promote the targets to be global due the XCB library already being found by one of the modules in QtBase. In case we wish to disable this fix, any module can simply specify QT_FIND_PACKAGE_DISABLE_DEBUG_BEHAVIOR=ON during configuration time. Change-Id: Id7f2ad12ddea941dda754361660c7606439cd5a4 Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cmake/QtBuild.cmake') diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index b3eafd8d9e..1937e1a2ff 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -4246,9 +4246,14 @@ macro(qt_find_package) # targets to be global. This behavior is not enabled by default, because there are cases # when a regular find_package() (non qt_) can find a package (Freetype -> PNG), and a subsequent # qt_find_package(PNG PROVIDED_TARGET PNG::PNG) still needs to succeed and register the provided - # targets. To enable the debugging behavior, set QT_DEBUG_QT_FIND_PACKAGE to 1. + # targets. + # Recently we have observed that some projects, such as QtVirtualKeyboard, will error out in + # static build because of the global promotion error. The previous code only enabled the if + # statement below when QT_DEBUG_QT_FIND_PACKAGE was set to true. Now we have this check enabled + # by default unless QT_FIND_PACKAGE_DISABLE_DEBUG_BEHAVIOR is defined and set to true. set(_qt_find_package_skip_find_package FALSE) - if(QT_DEBUG_QT_FIND_PACKAGE AND ${ARGV0}_FOUND AND arg_PROVIDED_TARGETS) + if((NOT DEFINED QT_FIND_PACKAGE_DISABLE_DEBUG_BEHAVIOR OR NOT QT_FIND_PACKAGE_DISABLE_DEBUG_BEHAVIOR) + AND ${ARGV0}_FOUND AND arg_PROVIDED_TARGETS) set(_qt_find_package_skip_find_package TRUE) foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS}) if(NOT TARGET ${qt_find_package_target_name}) -- cgit v1.2.3