summaryrefslogtreecommitdiffstats
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
authorDan Kegel <dank@kegel.com>2017-12-07 18:00:39 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2019-03-20 21:21:47 (GMT)
commitf401a5716025ecafc5c11da322eba25b77abee0c (patch)
treeb3d2e2a7bb981843747baf07fbc3c7d7eba50476 /Modules/FindPkgConfig.cmake
parent4d769419244aadb9742cafb06e704d3aa5cc10bc (diff)
downloadCMake-f401a5716025ecafc5c11da322eba25b77abee0c.zip
CMake-f401a5716025ecafc5c11da322eba25b77abee0c.tar.gz
CMake-f401a5716025ecafc5c11da322eba25b77abee0c.tar.bz2
pkg_get_variable now sets PKG_CONFIG_PATH like pkg_check_modules
Fixes: #15805
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake58
1 files changed, 34 insertions, 24 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index c852aaa..e05d5c8 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -84,26 +84,8 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
endif()
endmacro()
-#[========================================[.rst:
-.. command:: pkg_get_variable
-
- Retrieves the value of a pkg-config variable ``varName`` and stores it in the
- result variable ``resultVar`` in the calling scope.
-
- .. code-block:: cmake
-
- pkg_get_variable(<resultVar> <moduleName> <varName>)
-
- If ``pkg-config`` returns multiple values for the specified variable,
- ``resultVar`` will contain a :ref:`;-list <CMake Language Lists>`.
-
- For example:
-
- .. code-block:: cmake
-
- pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir)
-#]========================================]
-function (pkg_get_variable result pkg variable)
+# Internal version of pkg_get_variable; expects PKG_CONFIG_PATH to already be set
+function (_pkg_get_variable result pkg variable)
_pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}")
set("${result}"
"${prefix_result}"
@@ -294,12 +276,12 @@ macro(_pkg_set_path_internal)
_pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
endif()
- if(NOT "${_extra_paths}" STREQUAL "")
+ if(NOT _extra_paths STREQUAL "")
# Save the PKG_CONFIG_PATH environment variable, and add paths
# from the CMAKE_PREFIX_PATH variables
set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}")
set(_pkgconfig_path "${_pkgconfig_path_old}")
- if(NOT "${_pkgconfig_path}" STREQUAL "")
+ if(NOT _pkgconfig_path STREQUAL "")
file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
endif()
@@ -347,7 +329,7 @@ macro(_pkg_set_path_internal)
endforeach()
# Prepare and set the environment variable
- if(NOT "${_pkgconfig_path}" STREQUAL "")
+ if(NOT _pkgconfig_path STREQUAL "")
# remove empty values from the list
list(REMOVE_ITEM _pkgconfig_path "")
file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
@@ -365,7 +347,7 @@ macro(_pkg_set_path_internal)
endmacro()
macro(_pkg_restore_path_internal)
- if(NOT "${_extra_paths}" STREQUAL "")
+ if(NOT _extra_paths STREQUAL "")
# Restore the environment variable
set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
endif()
@@ -721,6 +703,34 @@ macro(pkg_search_module _prefix _module0)
endif()
endmacro()
+#[========================================[.rst:
+.. command:: pkg_get_variable
+
+ Retrieves the value of a pkg-config variable ``varName`` and stores it in the
+ result variable ``resultVar`` in the calling scope.
+
+ .. code-block:: cmake
+
+ pkg_get_variable(<resultVar> <moduleName> <varName>)
+
+ If ``pkg-config`` returns multiple values for the specified variable,
+ ``resultVar`` will contain a :ref:`;-list <CMake Language Lists>`.
+
+ For example:
+
+ .. code-block:: cmake
+
+ pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir)
+#]========================================]
+function (pkg_get_variable result pkg variable)
+ _pkg_set_path_internal()
+ _pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}")
+ set("${result}"
+ "${prefix_result}"
+ PARENT_SCOPE)
+ _pkg_restore_path_internal()
+endfunction ()
+
#[========================================[.rst:
Variables Affecting Behavior