diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-05 13:15:34 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-05 16:08:14 +0100 |
commit | 4f7cc722985fb52ea67f56dfb766bb274410ba2d (patch) | |
tree | d2a96bb9091c94aaed5e0cc7b9d408e26c71ec09 /cmake/QtFindWrapHelper.cmake | |
parent | a2305f94306013a0273b276955b3b2340a06a9e6 (diff) | |
download | qtbase-4f7cc722985fb52ea67f56dfb766bb274410ba2d.tar.gz |
CMake: Handle conditions in third party find modules correctly
Previously the FindWrap modules checked for hardcoded features
when deciding whether to use a bundled library or not. This proved
not to work correctly because features were not available when
the find modules were processed.
Introduce a new CMake API call that needs to be manually called
after an add_subdirectory call which declares a bundled library.
The call will check for the existence of the bundled target, and will
then set a cache variable QT_USE_BUNDLED_Bundled<TargetName>.
The same variable is written into a FindWrapFooConfigExtra.cmake file
which will be loaded by the appropriate FindWrap module. The module
can that use that variable to decided whether to link against the
bundled library or the system library.
Change-Id: I75e9a4f4e14d88d4490916a79ad12f1ce57891e0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake/QtFindWrapHelper.cmake')
-rw-r--r-- | cmake/QtFindWrapHelper.cmake | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cmake/QtFindWrapHelper.cmake b/cmake/QtFindWrapHelper.cmake index cb6d19600b..f536df99e1 100644 --- a/cmake/QtFindWrapHelper.cmake +++ b/cmake/QtFindWrapHelper.cmake @@ -19,7 +19,6 @@ macro(qt_find_package_system_or_bundled _unique_prefix) BUNDLED_PACKAGE_TARGET SYSTEM_PACKAGE_NAME SYSTEM_PACKAGE_TARGET - USE_BUNDLED_PACKAGE ) set(_multioptions "") @@ -36,11 +35,20 @@ macro(qt_find_package_system_or_bundled _unique_prefix) set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} OFF) - if(_qfwrap_${_unique_prefix}_USE_BUNDLED_PACKAGE) + include("FindWrap${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}ConfigExtra" OPTIONAL) + + if(NOT DEFINED "QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") + message(FATAL_ERROR + "Can't find cache variable " + "QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET} " + "to decide whether to use bundled or system library.") + endif() + + if("${QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}}") set(${_unique_prefix}_qt_package_name_to_use - "${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}") + "Qt6${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}") set(${_unique_prefix}_qt_package_target_to_use - "${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") + "Qt6::${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") set(${_unique_prefix}_qt_package_success_message "Using Qt bundled ${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}.") set(${_unique_prefix}_qt_package_type "bundled") @@ -69,6 +77,6 @@ macro(qt_find_package_system_or_bundled _unique_prefix) INTERFACE_QT_3RD_PARTY_PACKAGE_TYPE "${${_unique_prefix}_qt_package_type}") elseif(${_unique_prefix}_qt_package_type STREQUAL "bundled") - message(FATAL_ERROR "Can't find ${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}.") + message(FATAL_ERROR "Can't find ${${_unique_prefix}_qt_package_target_to_use}.") endif() endmacro() |