summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorCorentin Noël <corentin.noel@collabora.com>2023-09-17 16:44:26 (GMT)
committerCorentin Noël <corentin.noel@collabora.com>2023-09-19 07:08:48 (GMT)
commite0d00b9218bc458ae6cdd5e7ce514c0ba7b4dec4 (patch)
tree80e715b467497e994d9f2d24ee46e27fdfab0631 /Tests/RunCMake
parentaa6213848d66fa27049754e61a677dfc378e02d6 (diff)
downloadCMake-e0d00b9218bc458ae6cdd5e7ce514c0ba7b4dec4.zip
CMake-e0d00b9218bc458ae6cdd5e7ce514c0ba7b4dec4.tar.gz
CMake-e0d00b9218bc458ae6cdd5e7ce514c0ba7b4dec4.tar.bz2
FindPkgConfig: Allow to override variables when calling pkg_get_variable
This is specifically useful when building applications within containers as we sometimes need to redefine the prefix used in a variable.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake19
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake1
2 files changed, 20 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake
new file mode 100644
index 0000000..98f3cd6
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES.cmake
@@ -0,0 +1,19 @@
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+if(WIN32)
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch")
+else()
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch")
+endif()
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(BLETCH QUIET bletch)
+
+if (NOT BLETCH_FOUND)
+ message(FATAL_ERROR "Failed to find embedded package bletch via CMAKE_PREFIX_PATH")
+endif ()
+
+pkg_get_variable(bletchvar bletch exec_prefix DEFINE_VARIABLES prefix=customprefix)
+if (NOT bletchvar STREQUAL "customprefix")
+ message(FATAL_ERROR "Failed to fetch variable exec_prefix from embedded package bletch with prefix overridden to customprefix")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 2bfe028..7af425a 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -51,6 +51,7 @@ Libs: -L\${libdir}
endif()
endif()
run_cmake(FindPkgConfig_GET_VARIABLE)
+ run_cmake(FindPkgConfig_GET_VARIABLE_DEFINE_VARIABLES)
run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH)
run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_cache_variables)