summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-03-26 15:59:22 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-03-26 15:59:22 +0100
commitc24491c2c916220648802e5e711e923c7685ee9d (patch)
treeae362a7b7d8de6f343ad288f2821a0881b714b60
parented1f4eb5c9dc1ae02d95034551bf6640b393e754 (diff)
downloaduca-c24491c2c916220648802e5e711e923c7685ee9d.tar.gz
uca-c24491c2c916220648802e5e711e923c7685ee9d.tar.bz2
uca-c24491c2c916220648802e5e711e923c7685ee9d.tar.xz
uca-c24491c2c916220648802e5e711e923c7685ee9d.zip
Use pkg-config to determine GI support
-rw-r--r--CMakeLists.txt1
-rw-r--r--cmake/PkgConfigVars.cmake30
-rw-r--r--src/CMakeLists.txt11
3 files changed, 39 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d04287..e4053ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,6 +67,7 @@ endmacro()
#}}}
#{{{ Configure
include(ConfigurePaths)
+include(PkgConfigVars)
configure_paths(UCA)
set(UCA_PLUGINDIR "${UCA_LIBDIR}/uca")
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(<PKG_NAME> <VARIABLE_NAME>)
+#
+# Checks for a variable in the given package and translates to a call such as
+# `pkg-config --variable=<VARIABLE_NAME> <PKG_NAME>`. The output is a cached
+# variable named
+#
+# <PKG_NAME>_<VARIABLE_NAME>
+#
+# 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()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3d94c98..762b308 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -62,10 +62,15 @@ endif ()
#}}}
#{{{ GObject introspection
-if (INTROSPECTION_SCANNER AND INTROSPECTION_COMPILER)
+pkg_check_modules(GOBJECT_INTROSPECTION gobject-introspection-1.0)
+
+if (GOBJECT_INTROSPECTION_FOUND)
option(WITH_GIR "Build introspection files" ON)
if (WITH_GIR)
+ pkg_check_variable(gobject-introspection-1.0 g_ir_scanner)
+ pkg_check_variable(gobject-introspection-1.0 g_ir_compiler)
+
set(GIR_PREFIX "Uca-${UCA_ABI_VERSION}.0")
set(GIR_XML "${GIR_PREFIX}.gir")
set(GIR_TYPELIB "${GIR_PREFIX}.typelib")
@@ -79,7 +84,7 @@ if (INTROSPECTION_SCANNER AND INTROSPECTION_COMPILER)
list(APPEND _gir_input "${CMAKE_CURRENT_BINARY_DIR}/uca-enums.c")
add_custom_command(OUTPUT ${GIR_XML}
- COMMAND ${INTROSPECTION_SCANNER}
+ COMMAND ${GOBJECT_INTROSPECTION_1.0_G_IR_SCANNER}
--namespace=Uca
--nsversion=${UCA_ABI_VERSION}
--library=uca
@@ -94,7 +99,7 @@ if (INTROSPECTION_SCANNER AND INTROSPECTION_COMPILER)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(OUTPUT ${GIR_TYPELIB}
- COMMAND ${INTROSPECTION_COMPILER}
+ COMMAND ${GOBJECT_INTROSPECTION_1.0_G_IR_COMPILER}
-o ${GIR_TYPELIB}
${GIR_XML}
DEPENDS ${GIR_XML}