More tests for pkg_get_variable

Issue: #15805
This commit is contained in:
Dan Kegel
2017-12-07 08:00:14 -08:00
committed by Ben Boeckel
parent f2d3e233cd
commit 78f23de70c
4 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# Prepare environment and variables
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
if(WIN32)
set(ENV{CMAKE_PREFIX_PATH} "C:\\baz")
set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch\\lib\\pkgconfig;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
else()
set(ENV{CMAKE_PREFIX_PATH} "/baz")
set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig:/this/directory/should/not/exist/in/the/filesystem")
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 PKG_CONFIG_PATH")
endif ()
pkg_get_variable(bletchvar bletch jackpot)
if (NOT bletchvar STREQUAL "bletch-lives")
message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via PKG_CONFIG_PATH")
endif ()

View File

@@ -0,0 +1,21 @@
# 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;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
set(ENV{PKG_CONFIG_PATH} "C:\\baz")
else()
set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch:/this/directory/should/not/exist/in/the/filesystem")
set(ENV{PKG_CONFIG_PATH} "/baz")
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 jackpot)
if (NOT bletchvar STREQUAL "bletch-lives")
message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via CMAKE_PREFIX_PATH")
endif ()

View File

@@ -14,6 +14,9 @@ endif()
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_GET_VARIABLE)
# Disable this one until https://gitlab.kitware.com/cmake/cmake/issues/15805 fixed
#run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH)
run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_cache_variables)
run_cmake(FindPkgConfig_IMPORTED_TARGET)
run_cmake(FindPkgConfig_VERSION_OPERATORS)

View File

@@ -0,0 +1,12 @@
prefix=/opt/bletch
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
jackpot=bletch-lives
Name: Bletch
Description: Dummy packaget to test variable support
Version: 1.0
Libs: -L${libdir} -lbletch
Cflags: -Dbletch_version=1