From 907acd5de267faa2740229ffbe44d030b9413d90 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 23 Sep 2016 09:26:48 +0200 Subject: "Build"/install also GSettings schemas --- addressbook/libebook-contacts/CMakeLists.txt | 5 ++- cmake/modules/GLibTools.cmake | 51 ++++++++++++++++++++++++++++ libebackend/CMakeLists.txt | 2 ++ libedataserver/CMakeLists.txt | 16 +++++++-- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/addressbook/libebook-contacts/CMakeLists.txt b/addressbook/libebook-contacts/CMakeLists.txt index 615e6f7a0..3ea845c19 100644 --- a/addressbook/libebook-contacts/CMakeLists.txt +++ b/addressbook/libebook-contacts/CMakeLists.txt @@ -137,7 +137,10 @@ set(gir_cflags -I${CMAKE_SOURCE_DIR}/addressbook -I${CMAKE_SOURCE_DIR}/addressbook/libebook-contacts ) -set(gir_libdirs ${CMAKE_BINARY_DIR}/private) +set(gir_libdirs + ${CMAKE_BINARY_DIR}/private + ${CMAKE_BINARY_DIR}/libedataserver +) set(gir_libs ebook-contacts edataserver diff --git a/cmake/modules/GLibTools.cmake b/cmake/modules/GLibTools.cmake index eed32e0e0..393a91c5d 100644 --- a/cmake/modules/GLibTools.cmake +++ b/cmake/modules/GLibTools.cmake @@ -30,6 +30,12 @@ # gdbus_codegen_custom(_xml _interface_prefix _c_namespace _files_prefix _list_gens _args) # The same as gdbus_codegen() except allows to pass other arguments to the call, # like for example --c-generate-object-manager +# +# add_gsettings_schemas(_target _schema0 ...) +# Adds one or more GSettings schemas. The extension is supposed to be .gschema.xml. The schema file generation +# is added as a dependency of _target. + +include(PkgConfigEx) find_program(GLIB_MKENUMS glib-mkenums) if(NOT GLIB_MKENUMS) @@ -143,3 +149,48 @@ endfunction(gdbus_codegen_custom) function(gdbus_codegen _xml _interface_prefix _c_namespace _files_prefix _list_gens) gdbus_codegen_custom(${_xml} ${_interface_prefix} ${_c_namespace} ${_files_prefix} ${_list_gens} "") endfunction(gdbus_codegen) + +add_printable_option(ENABLE_SCHEMAS_COMPILE "Enable GSettings regeneration of gschemas.compile on install" ON) + +if(CMAKE_CROSSCOMPILING) + find_program(GLIB_COMPILE_SCHEMAS glib-compile-schemas) +else(CMAKE_CROSSCOMPILING) + pkg_check_variable(GLIB_COMPILE_SCHEMAS gio-2.0 glib_compile_schemas) +endif(CMAKE_CROSSCOMPILING) + +if(NOT GLIB_COMPILE_SCHEMAS) + message(FATAL_ERROR "Cannot find glib-compile-schemas, which is required to build ${PROJECT_NAME}") +endif(NOT GLIB_COMPILE_SCHEMAS) + +set(GSETTINGS_SCHEMAS_DIR "${SHARE_INSTALL_DIR}/glib-2.0/schemas/") + +macro(add_gsettings_schemas _target _schema0) + foreach(_schema ${_schema0} ${ARGN}) + string(REPLACE ".xml" ".valid" _outputfile "${_schema}") + add_custom_command( + OUTPUT ${_outputfile} + COMMAND ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${_schema} + COMMAND cmake -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${_schema}" "${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}" + VERBATIM + ) + add_custom_target(gsettings-schemas-${_schema} ALL DEPENDS ${_outputfile}) + add_dependencies(${_target} gsettings-schemas-${_schema}) + install(FILES ${_schema} + DESTINATION ${GSETTINGS_SCHEMAS_DIR}) + endforeach(_schema) +endmacro(add_gsettings_schemas) + +# This is called too early, when the schemas are not installed yet during `make install` +# +# compile_gsettings_schemas() +# Optionally (based on ENABLE_SCHEMAS_COMPILE) recompiles schemas at the destination folder +# after install. It's necessary to call it as the last command in the toplevel CMakeLists.txt, +# thus the compile runs when all the schemas are installed. +# +#macro(compile_gsettings_schemas) +# if(ENABLE_SCHEMAS_COMPILE) +# install(CODE +# "message(STATUS \"Compiling GSettings schemas at '${GSETTINGS_SCHEMAS_DIR}'\") +# execute_process(COMMAND cmake -E chdir . \"${GLIB_COMPILE_SCHEMAS}\" \"${GSETTINGS_SCHEMAS_DIR}\")") +# endif(ENABLE_SCHEMAS_COMPILE) +#endmacro(compile_gsettings_schemas) diff --git a/libebackend/CMakeLists.txt b/libebackend/CMakeLists.txt index 0deb6f0ac..3bf371d84 100644 --- a/libebackend/CMakeLists.txt +++ b/libebackend/CMakeLists.txt @@ -132,3 +132,5 @@ install(TARGETS ebackend install(FILES ${HEADERS} DESTINATION ${privincludedir}/libebackend ) + +add_gsettings_schemas(ebackend org.gnome.evolution.eds-shell.gschema.xml) diff --git a/libedataserver/CMakeLists.txt b/libedataserver/CMakeLists.txt index 4e5e13bb7..3c89ced2a 100644 --- a/libedataserver/CMakeLists.txt +++ b/libedataserver/CMakeLists.txt @@ -262,9 +262,19 @@ install(FILES ${HEADERS} set(gir_sources ${SOURCES} ${HEADERS}) set(gir_identifies_prefixes E) set(gir_includes GObject-2.0 Gio-2.0 Soup-2.4 libxml2-2.0) -set(gir_cflags ${CAMEL_CFLAGS} ${DATA_SERVER_CFLAGS} -DLIBEDATASERVER_COMPILATION) -set(gir_libdirs ${CMAKE_BINARY_DIR}/private) -set(gir_libs camel edataserver) +set(gir_cflags + ${CAMEL_CFLAGS} + ${DATA_SERVER_CFLAGS} + -DLIBEDATASERVER_COMPILATION +) +set(gir_libdirs + ${CMAKE_BINARY_DIR}/private + ${CMAKE_BINARY_DIR}/camel +) +set(gir_libs + camel + edataserver +) set(gir_deps) gir_filter_out_sources(gir_sources e-sexp.h) -- cgit v1.2.1