From 796a887cf88c1ad23ab06e89435ca1e04080aaee Mon Sep 17 00:00:00 2001 From: Pete Woods Date: Fri, 16 Aug 2013 04:13:41 +0100 Subject: Build using cmake --- cmake/UseGSettings.cmake | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cmake/UseGSettings.cmake (limited to 'cmake/UseGSettings.cmake') diff --git a/cmake/UseGSettings.cmake b/cmake/UseGSettings.cmake new file mode 100644 index 0000000..92eb681 --- /dev/null +++ b/cmake/UseGSettings.cmake @@ -0,0 +1,42 @@ +# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them. + +option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" ${LOCAL_INSTALL}) + +option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL}) + +if(GSETTINGS_LOCALINSTALL) + message(STATUS "GSettings schemas will be installed locally.") +endif() + +if(GSETTINGS_COMPILE) + message(STATUS "GSettings shemas will be compiled.") +endif() + +macro(add_schema SCHEMA_NAME) + + set(PKG_CONFIG_EXECUTABLE pkg-config) + # Have an option to not install the schema into where GLib is + if (GSETTINGS_LOCALINSTALL) + SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/") + else (GSETTINGS_LOCALINSTALL) + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) + SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/") + endif (GSETTINGS_LOCALINSTALL) + + # Run the validator and error if it fails + execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_schemas_invalid) + message (SEND_ERROR "Schema validation error: ${_schemas_invalid}") + endif (_schemas_invalid) + + # Actually install and recomple schemas + message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}") + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL) + + if (GSETTINGS_COMPILE) + install (CODE "message (STATUS \"Compiling GSettings schemas\")") + install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})") + endif () +endmacro() -- cgit v1.2.3 From be867b88006520083a148785e8db761730b85eff Mon Sep 17 00:00:00 2001 From: Pete Woods Date: Fri, 16 Aug 2013 05:33:21 +0100 Subject: Fix up defaults --- cmake/UseGSettings.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake/UseGSettings.cmake') diff --git a/cmake/UseGSettings.cmake b/cmake/UseGSettings.cmake index 92eb681..e109692 100644 --- a/cmake/UseGSettings.cmake +++ b/cmake/UseGSettings.cmake @@ -1,8 +1,8 @@ # GSettings.cmake, CMake macros written for Marlin, feel free to re-use them. -option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" ${LOCAL_INSTALL}) +option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" OFF) -option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL}) +option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" OFF) if(GSETTINGS_LOCALINSTALL) message(STATUS "GSettings schemas will be installed locally.") -- cgit v1.2.3