summaryrefslogtreecommitdiffstats
path: root/CMakeScripts/HelperFunctions.cmake
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2015-05-01 03:52:17 +0000
committer~suv <suv-sf@users.sourceforge.net>2015-05-01 03:52:17 +0000
commit3c185d781ac7a7031397c6651baf046d900efc3a (patch)
tree0ceed4b570a0c57a48e7bbff12c255f751959ef0 /CMakeScripts/HelperFunctions.cmake
parentFixed crash bug due to some overlooked function changed in the recent merge. (diff)
downloadinkscape-3c185d781ac7a7031397c6651baf046d900efc3a.tar.gz
inkscape-3c185d781ac7a7031397c6651baf046d900efc3a.zip
cmake: Fix osx-related issues with cmake-build
Add new helper function to retrive pkg-config variables in Cmake; use paths defined as environment variables for builds on OS X (useful if MacPorts is not installed into default prefix); check backend of GTK2 on OS X in main cmake file (x11|quartz). (bzr r14080)
Diffstat (limited to 'CMakeScripts/HelperFunctions.cmake')
-rw-r--r--CMakeScripts/HelperFunctions.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/CMakeScripts/HelperFunctions.cmake b/CMakeScripts/HelperFunctions.cmake
new file mode 100644
index 000000000..0e6fff51a
--- /dev/null
+++ b/CMakeScripts/HelperFunctions.cmake
@@ -0,0 +1,19 @@
+# pkg_check_variable() - a function to retrieve pkg-config variables in CMake
+#
+# source: http://bloerg.net/2015/03/06/pkg-config-variables-in-cmake.html
+
+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()