cmake: Correct way to save/restore env vars

for pkgconfig it is different if they are not defined vs an empty string

Change-Id: Ifb05db5dab32a699aafa32d91f9719eab78dee44
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Albert Astals Cid 2019-05-10 17:50:51 +02:00
parent 400f94109d
commit 6396d46f55

View File

@ -1,10 +1,31 @@
# DBus1 is buggy and breaks PKG_CONFIG environment.
# Work around that:-/
# See https://gitlab.freedesktop.org/dbus/dbus/issues/267 for more information
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()
set(__qt_dbus_pcd $ENV{PKG_CONFIG_DIR})
set(__qt_dbus_pcp $ENV{PKG_CONFIG_PATH})
set(__qt_dbus_pcl $ENV{PKG_CONFIG_LIBDIR})
find_package(DBus1)
set(ENV{PKG_CONFIG_DIR} ${__qt_dbus_pcd})
set(ENV{PKG_CONFIG_PATH} ${__qt_dbus_pcp})
set(ENV{PKG_CONFIG_LIBDIR} ${__qt_dbus_pcl})
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()