~unity-team/libusermetrics/trunk

« back to all changes in this revision

Viewing changes to cmake/UseGSettings.cmake

  • Committer: Bileto Bot
  • Author(s): Pete Woods
  • Date: 2016-12-08 10:50:56 UTC
  • mfrom: (233.1.7 trunk)
  • Revision ID: ci-train-bot@canonical.com-20161208105056-teqkoq2t6ktx9d2e
Compatibility with unversioned cmake-extras modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them.
2
 
 
3
 
option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL})
4
 
 
5
 
if(GSETTINGS_COMPILE)
6
 
    message(STATUS "GSettings schemas will be compiled.")
7
 
endif()
8
 
 
9
 
macro(add_schema SCHEMA_NAME)
10
 
    set(PKG_CONFIG_EXECUTABLE pkg-config)
11
 
    SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/")
12
 
 
13
 
    # Run the validator and error if it fails
14
 
    execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas  OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
15
 
    execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
16
 
 
17
 
    if (_schemas_invalid)
18
 
      message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
19
 
    endif (_schemas_invalid)
20
 
 
21
 
    # Actually install and recomple schemas
22
 
    message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
23
 
    install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
24
 
 
25
 
    if (GSETTINGS_COMPILE)
26
 
        install (CODE "message (STATUS \"Compiling GSettings schemas\")")
27
 
        install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})")
28
 
    endif ()
29
 
endmacro()