From c24491c2c916220648802e5e711e923c7685ee9d Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 26 Mar 2015 15:59:22 +0100 Subject: Use pkg-config to determine GI support --- cmake/PkgConfigVars.cmake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cmake/PkgConfigVars.cmake (limited to 'cmake') diff --git a/cmake/PkgConfigVars.cmake b/cmake/PkgConfigVars.cmake new file mode 100644 index 0000000..f295457 --- /dev/null +++ b/cmake/PkgConfigVars.cmake @@ -0,0 +1,30 @@ +# - determine variables defined in pkg-config files +# +# Usage: +# pkg_check_variable( ) +# +# Checks for a variable in the given package and translates to a call such as +# `pkg-config --variable= `. The output is a cached +# variable named +# +# _ +# +# Note that both names are uppercased and any dashes replaced by underscores. +# + +find_package(PkgConfig REQUIRED) + +function(pkg_check_variable _pkg _name) + string(TOUPPER ${_pkg} _pkg_upper) + string(TOUPPER ${_name} _name_upper) + string(REPLACE "-" "_" _pkg_upper ${_pkg_upper}) + string(REPLACE "-" "_" _name_upper ${_name_upper}) + set(_output_name "${_pkg_upper}_${_name_upper}") + + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_name} ${_pkg} + OUTPUT_VARIABLE _pkg_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set("${_output_name}" "${_pkg_result}" CACHE STRING "pkg-config variable + ${_name} of ${_pkg}") +endfunction() -- cgit v1.2.3