qt5base-lts/cmake/FindWrapPNG.cmake
Alexandru Croitor 4f7cc72298 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>
2020-03-05 16:08:14 +01:00

12 lines
392 B
CMake

include(QtFindWrapHelper NO_POLICY_SCOPE)
qt_find_package_system_or_bundled(wrap_png
FRIENDLY_PACKAGE_NAME "PNG"
WRAP_PACKAGE_TARGET "WrapPNG::WrapPNG"
WRAP_PACKAGE_FOUND_VAR_NAME "WrapPNG_FOUND"
BUNDLED_PACKAGE_NAME "BundledLibpng"
BUNDLED_PACKAGE_TARGET "BundledLibpng"
SYSTEM_PACKAGE_NAME "WrapSystemPNG"
SYSTEM_PACKAGE_TARGET "WrapSystemPNG::WrapSystemPNG"
)