cmake: Avoid overwriting PKG_CONFIG_PATH env var
authorClemens Lang <clemens.lang@bmw-carit.de>
Fri, 8 Feb 2019 14:48:15 +0000 (15:48 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 13 May 2019 09:36:11 +0000 (10:36 +0100)
commit6e432ed51e8f9ff62d935a0a568385144d97afbf
tree4edebd372a316dd5b5ec7eb42bc1261610693c9b
parent7642acca6d20d8c537a7aafe05cefaa8b213d953
cmake: Avoid overwriting PKG_CONFIG_PATH env var

The CMake config file installed by DBus will run in the context of other
projects. Consequently, changing the value of the PKG_CONFIG_DIR,
PKG_CONFIG_PATH or PKG_CONFIG_LIBDIR environment variables will affect
any further calls to pkg-config made by such projects, which can cause
problems.

A common case of this happening are pkg-config files installed in
usr/share/pkgconfig for .pc files that are architecture-independent, as
for example systemd does.

Avoid clobbering the environment variables by saving and restoring their
values. Note that for some of the variables, setting them to an empty
string is different from not setting them at all.

Signed-off-by: Clemens Lang <clemens.lang@bmw-carit.de>
(cherry picked from commit 3525cc045d4c683dfc6048f5be795cc372c323a3)
Closes: dbus#267
cmake/DBus1Config.pkgconfig.in