summaryrefslogtreecommitdiff
path: root/Modules/FindPkgConfig.cmake
diff options
context:
space:
mode:
authorAlex Birch <51103-Birchlabs@users.noreply.gitlab.kitware.com>2021-12-31 16:48:56 +0000
committerBrad King <brad.king@kitware.com>2022-05-12 12:26:04 -0400
commit5cfbc763716c1e15ee20a24c503b9b7371a2da28 (patch)
tree72220ba4c1036cccb0e9c933d5f59575a9d33dec /Modules/FindPkgConfig.cmake
parent364fde65ee93588cb519ece09b161c0e8e826c3c (diff)
downloadcmake-5cfbc763716c1e15ee20a24c503b9b7371a2da28.tar.gz
FindPkgConfig: Fix parsing of backslash-escaped spaces in pkg-config output
Treat backslash-escaped spaces as "space within argument" rather than "space delimiting arguments". Update our `FindPkgConfig_LIBRARY_PATH` test case to escape spaces in the path, and run it unconditionally.
Diffstat (limited to 'Modules/FindPkgConfig.cmake')
-rw-r--r--Modules/FindPkgConfig.cmake4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 547bc520da..ffcd8b7e70 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -143,7 +143,9 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
endif()
- separate_arguments(_pkgconfig_invoke_result)
+ # pkg-config can represent "spaces within an argument" by backslash-escaping the space.
+ # UNIX_COMMAND mode treats backslash-escaped spaces as "not a space that delimits arguments".
+ separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}")
#message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}")
set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})