qt5base-lts/cmake/FindWrapDBus1.cmake
Alexandru Croitor 3c52f8af9d CMake: pro2cmake: Specify library versions for 3rd party libraries
If certain 3rd party libraries have a version that's not suitable for
Qt, the configure summary should say so, rather than use them and fail
at build time.

With the current situation, we have to duplicate the version
information from the configure.json files in helper.py, by assigning
the version number as an extra find_package variable.

Rerunning configurejson2cmake then embeds this version info into the
qt_find_package calls in configure.cmake.

Some of the Find modules are rewritten to take the  specified version
into account when looking for the libraries.
This involves moving around the code for creating a target, after
calling find_package_handle_standard_args() so we know if a good
enough version was found.

Task-number: QTBUG-82917
Change-Id: I139748d8090e0630cda413362760034dc3483e11
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-10 11:56:54 +02:00

48 lines
1.3 KiB
CMake

# DBus1 is buggy and breaks PKG_CONFIG environment.
# Work around that:-/
# See https://gitlab.freedesktop.org/dbus/dbus/issues/267 for more information
# When doing top-level static Qt builds, we need to protect against double creation of the dbus
# target.
if(DBus1_FOUND OR WrapDBus1_FOUND OR TARGET dbus-1)
set(WrapDBus1_FOUND 1)
return()
endif()
if(DEFINED ENV{PKG_CONFIG_DIR})
set(__qt_dbus_pcd "$ENV{PKG_CONFIG_DIR}")
endif()
if(DEFINED ENV{PKG_CONFIG_PATH})
set(__qt_dbus_pcp "$ENV{PKG_CONFIG_PATH}")
endif()
if(DEFINED ENV{PKG_CONFIG_LIBDIR})
set(__qt_dbus_pcl "$ENV{PKG_CONFIG_LIBDIR}")
endif()
find_package(DBus1 ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} QUIET)
if(DEFINED __qt_dbus_pcd)
set(ENV{PKG_CONFIG_DIR} "${__qt_dbus_pcd}")
else()
unset(ENV{PKG_CONFIG_DIR})
endif()
if(DEFINED __qt_dbus_pcp)
set(ENV{PKG_CONFIG_PATH} "${__qt_dbus_pcp}")
else()
unset(ENV{PKG_CONFIG_PATH})
endif()
if(DEFINED __qt_dbus_pcl)
set(ENV{PKG_CONFIG_LIBDIR} "${__qt_dbus_pcl}")
else()
unset(ENV{PKG_CONFIG_LIBDIR})
endif()
if(DBus1_FOUND)
set(WrapDBus1_FOUND 1)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapDBus1 REQUIRED_VARS
DBus1_LIBRARY DBus1_INCLUDE_DIR WrapDBus1_FOUND
VERSION_VAR DBus1_VERSION)