summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/FindPkgConfig
diff options
context:
space:
mode:
authorAlex Birch <51103-Birchlabs@users.noreply.gitlab.kitware.com>2021-12-31 16:48:56 (GMT)
committerBrad King <brad.king@kitware.com>2022-05-12 16:26:04 (GMT)
commit5cfbc763716c1e15ee20a24c503b9b7371a2da28 (patch)
tree72220ba4c1036cccb0e9c933d5f59575a9d33dec /Tests/RunCMake/FindPkgConfig
parent364fde65ee93588cb519ece09b161c0e8e826c3c (diff)
downloadCMake-5cfbc763716c1e15ee20a24c503b9b7371a2da28.zip
CMake-5cfbc763716c1e15ee20a24c503b9b7371a2da28.tar.gz
CMake-5cfbc763716c1e15ee20a24c503b9b7371a2da28.tar.bz2
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 'Tests/RunCMake/FindPkgConfig')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt4
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake19
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake5
3 files changed, 15 insertions, 13 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt
index 6615d80..539e5ef 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt
@@ -1,3 +1,3 @@
-- ZOT_LIBRARIES='zot'
--- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib/prefix-zot-suffix'
--- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib;-lzot'
+-- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib/prefix-zot-suffix'
+-- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib;-lzot'
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake
index 9f654b5..1278c49 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake
@@ -1,11 +1,16 @@
find_package(PkgConfig REQUIRED)
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig/zot.pc" "
-prefix=${CMAKE_CURRENT_BINARY_DIR}/zot
+set(ROOT "${CMAKE_CURRENT_BINARY_DIR}/root")
+string(REPLACE " " "\\ " ESCAPED_ROOT "${ROOT}")
+set(LIB_DIR "${ROOT}/lib")
+set(PKGCONFIG_DIR "${LIB_DIR}/pkgconfig")
+
+file(WRITE "${PKGCONFIG_DIR}/zot.pc" "
+prefix=${ESCAPED_ROOT}
libdir=\${prefix}/lib
Name: Zot
-Description: Dummy packaget to test LIBRARY_DIR support
+Description: Dummy package to test LIBRARY_DIR support
Version: 1.0
Libs: -L\${libdir} -lzot
")
@@ -13,15 +18,15 @@ Libs: -L\${libdir} -lzot
# Create a "library" file to find in libdir.
set(CMAKE_FIND_LIBRARY_PREFIXES "prefix-")
set(CMAKE_FIND_LIBRARY_SUFFIXES "-suffix")
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/prefix-zot-suffix")
+file(WRITE "${LIB_DIR}/prefix-zot-suffix")
# 'pkg-config --libs' drops -L flags in PKG_CONFIG_SYSTEM_LIBRARY_PATH by default.
-set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib")
+set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${LIB_DIR}")
# 'pkgconf --libs' also drops -L flags in LIBRARY_PATH by default.
-set(ENV{LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib")
+set(ENV{LIBRARY_PATH} "${LIB_DIR}")
-set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig")
+set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_DIR}")
pkg_check_modules(ZOT REQUIRED zot)
message(STATUS "ZOT_LIBRARIES='${ZOT_LIBRARIES}'")
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index f36d1eb..f479dcf 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -32,8 +32,5 @@ if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_VERSION_OPERATORS)
run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME)
run_cmake(FindPkgConfig_empty_target)
-
- if(NOT RunCMake_BINARY_DIR MATCHES " ")
- run_cmake(FindPkgConfig_LIBRARY_PATH)
- endif()
+ run_cmake(FindPkgConfig_LIBRARY_PATH)
endif ()