summaryrefslogtreecommitdiff
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-07-13 10:28:48 -0400
committerBrad King <brad.king@kitware.com>2021-07-13 10:33:16 -0400
commit36979f5b438b39599b074a291ad3cca3bfafc6bc (patch)
treeabe174f084aaf47e6bf177ff72c555de11fe84e1 /Modules/FindPkgConfig.cmake
parent460e812369db398da34e14c9d40c3ecec06afaf1 (diff)
downloadcmake-36979f5b438b39599b074a291ad3cca3bfafc6bc.tar.gz
FindPkgConfig: Tolerate PKG_CONFIG_SYSTEM_LIBRARY_PATH in environment
Tell `pkg-config --libs` not to filter out `-L` flags for entries of `PKG_CONFIG_SYSTEM_LIBRARY_PATH` (and `LIBRARY_PATH` for `pkgconf`). We should always search everywhere the `.pc` file expects. Fixes: #22148
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index d39bbd03a8..a28f6bcd1f 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -403,6 +403,14 @@ macro(_pkg_set_path_internal)
unset(_lib_dirs)
unset(_pkgconfig_path)
endif()
+
+ # Tell pkg-config not to strip any -L paths so we can search them all.
+ if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS})
+ set(_pkgconfig_allow_system_libs_old "$ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}")
+ else()
+ unset(_pkgconfig_allow_system_libs_old)
+ endif()
+ set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 0)
endmacro()
macro(_pkg_restore_path_internal)
@@ -410,6 +418,10 @@ macro(_pkg_restore_path_internal)
# Restore the environment variable
set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
endif()
+ if(DEFINED _pkgconfig_allow_system_libs_old)
+ set(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} "${_pkgconfig_allow_system_libs_old}")
+ unset(_pkgconfig_allow_system_libs_old)
+ endif()
unset(_extra_paths)
unset(_pkgconfig_path_old)