From 6def7fceae5ea55e6d44ede05146f6a95add317c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 20 Jun 2013 17:31:07 -0500 Subject: install .schema.xml and indicator-session-service in the right places. --- CMakeLists.txt | 3 +- TODO | 2 + cmake/GSettings.cmake | 108 ----------------------------------------------- cmake/UseGSettings.cmake | 43 +++++++++++++++++++ data/CMakeLists.txt | 66 ++++++++++++++++++----------- src/CMakeLists.txt | 7 +-- 6 files changed, 93 insertions(+), 136 deletions(-) delete mode 100644 cmake/GSettings.cmake create mode 100644 cmake/UseGSettings.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f656cb4..d90d6c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ find_package(PkgConfig REQUIRED) include (GNUInstallDirs) include (FindPkgConfig) include (GdbusCodegen) -include (GSettings) +include (UseGSettings) add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" ) add_definitions (-DGNOMELOCALEDIR=\"@CMAKE_INSTALL_PREFIX@/share/locale\") @@ -51,6 +51,7 @@ if (EXISTS "/etc/debian_version") set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}") endif() message("Installing libexec files to ${CMAKE_INSTALL_FULL_LIBEXECDIR}") +set (PROJECT_LIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}") if(${LOCAL_INSTALL}) set(DBUSSERVICEDIR "${CMAKE_INSTALL_DATADIR}/dbus-1/services/") diff --git a/TODO b/TODO index 56c6a68..3d79bab 100644 --- a/TODO +++ b/TODO @@ -6,5 +6,7 @@ code cmake x add cmake rule to install .indicator file x add cmake rule to install dbus service file + x add cmake rule to install indicator-session-service + x gsettings schema validation - icon installation - test schema installation diff --git a/cmake/GSettings.cmake b/cmake/GSettings.cmake deleted file mode 100644 index 5902baa..0000000 --- a/cmake/GSettings.cmake +++ /dev/null @@ -1,108 +0,0 @@ -# GSettings.cmake -# Originally based on CMake macros written for Marlin -# Updated by Yorba for newer versions of GLib. -# -# NOTE: This module does an in-place compilation of GSettings; the -# resulting gschemas.compiled file will end up in the same -# source folder as the original schema(s). - -option(GSETTINGS_COMPILE "Compile GSettings schemas. Can be disabled for packaging reasons." ON) -option(GSETTINGS_COMPILE_IN_PLACE "Compile GSettings schemas in the build folder. This is used for running an appliction without installing the GSettings systemwide. The application will need to set GSETTINGS_SCHEMA_DIR" ON) - -if (GSETTINGS_COMPILE) - message(STATUS "GSettings schemas will be compiled.") -endif () - -if (GSETTINGS_COMPILE_IN_PLACE) - message(STATUS "GSettings schemas will be compiled in-place.") -endif () - -macro(add_schemas GSETTINGS_TARGET SCHEMA_DIRECTORY) - set(PKG_CONFIG_EXECUTABLE pkg-config) - - # Locate all schema files. - file(GLOB all_schema_files - "${SCHEMA_DIRECTORY}/*.gschema.xml" - ) - - # Find the GLib path for schema installation - 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/" CACHE INTERNAL "") - - # Fetch path for schema compiler from pkg-config - execute_process( - COMMAND - ${PKG_CONFIG_EXECUTABLE} - gio-2.0 - --variable - glib_compile_schemas - OUTPUT_VARIABLE - _glib_compile_schemas - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - set(glib_schema_compiler ${_glib_compile_schemas} CACHE INTERNAL "") - - if (GSETTINGS_COMPILE_IN_PLACE) - set(COMPILE_IN_PLACE_DIR ${CMAKE_BINARY_DIR}/gsettings) - add_custom_command( - TARGET - ${GSETTINGS_TARGET} - COMMAND - ${CMAKE_COMMAND} -E make_directory "${COMPILE_IN_PLACE_DIR}" - ) - - # Copy all schemas to the build folder. - foreach(schema_file ${all_schema_files}) - add_custom_command( - TARGET - ${GSETTINGS_TARGET} - COMMAND - ${CMAKE_COMMAND} -E copy "${schema_file}" "${COMPILE_IN_PLACE_DIR}" - COMMENT "Copying schema ${schema_file} to ${COMPILE_IN_PLACE_DIR}" - ) - endforeach() - - # Compile schema in-place. - add_custom_command( - TARGET - ${GSETTINGS_TARGET} - COMMAND - ${glib_schema_compiler} ${COMPILE_IN_PLACE_DIR} - COMMENT "Compiling schemas in folder: ${COMPILE_IN_PLACE_DIR}" - ) - endif () - - # Install and recompile schemas - message(STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}") - - install( - FILES - ${all_schema_files} - DESTINATION - ${GSETTINGS_DIR} - OPTIONAL - ) - - if (GSETTINGS_COMPILE) - install( - CODE - "message (STATUS \"Compiling GSettings schemas\")" - ) - - install( - CODE - "execute_process (COMMAND ${glib_schema_compiler} ${GSETTINGS_DIR})" - ) - endif () -endmacro(add_schemas) - diff --git a/cmake/UseGSettings.cmake b/cmake/UseGSettings.cmake new file mode 100644 index 0000000..3d8ae1c --- /dev/null +++ b/cmake/UseGSettings.cmake @@ -0,0 +1,43 @@ +# 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=${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 ${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() + diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 84fe66c..d8f338b 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,24 +1,42 @@ -# schema -configure_file (com.canonical.indicator.session.gschema.xml.in - com.canonical.indicator.session.gschema.xml) -include (GSettings) -add_schemas(clinica-schemas ${CMAKE_SOURCE_DIR}/data/com.canonical.indicator.session.gschema.xml) - -# .service file -set(SERVICE_NAME "indicator-session.service") -set(SERVICE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${SERVICE_NAME}") -set(pkglibexecdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/indicator-session") -configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/${SERVICE_NAME}.in" "${SERVICE_PATH}") -install (FILES ${SERVICE_PATH} - DESTINATION ${DBUSSERVICEDIR}) - -# .indicator file -install(FILES com.canonical.indicator.session - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/unity/indicators) - -# FIXME install files -# -#install(FILES -#datetime-dialog.ui -#DESTINATION share/indicatore-datetime # FIXME this too. -#) +## +## GSettings schema +## + +set (SCHEMA_NAME "com.canonical.indicator.session.gschema.xml") +set (SCHEMA_PATH "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}") +set (SCHEMA_PATH_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in") + +# generate the .xml file using intltool +set (ENV{LC_ALL} "C") +execute_process (COMMAND intltool-merge -x -u --no-translations ${SCHEMA_PATH_IN} ${SCHEMA_PATH}) + +# let UseGSettings do the rest +add_schema (${SCHEMA_PATH}) + + +## +## DBus Service File +## + +set (SERVICE_NAME "${CMAKE_PROJECT_NAME}.service") +set (SERVICE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${SERVICE_NAME}") +set (SERVICE_PATH_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SERVICE_NAME}.in") + +# build it +set (pkglibexecdir "${PROJECT_LIBEXECDIR}") +configure_file ("${SERVICE_PATH_IN}" "${SERVICE_PATH}") + +# install it +install (FILES ${SERVICE_PATH} DESTINATION ${DBUSSERVICEDIR}) + + +## +## Unity Indicator File +## + +set (UNITY_INDICATOR_NAME "com.canonical.indicator.session") +set (UNITY_INDICATOR_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_INDICATOR_NAME}") +set (UNITY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share/unity") + +install (FILES ${UNITY_INDICATOR_PATH} DESTINATION "${UNITY_INSTALL_PREFIX}/indicators") + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efa704c..7b65629 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,7 @@ set_target_properties (libindicatorsessionservice PROPERTIES COMPILE_FLAGS " -g include_directories(${SERVICE_INCLUDE_DIRS}) link_directories(${SERVICE_LIBRARY_DIRS}) -add_executable (indicator-session-service main.c) -target_link_libraries (indicator-session-service libindicatorsessionservice backenddbus ${SERVICE_LIBRARIES} ${GCOV_LIBS}) - +set (SERVICE_EXEC "indicator-session-service") +add_executable (${SERVICE_EXEC} main.c) +target_link_libraries (${SERVICE_EXEC} libindicatorsessionservice backenddbus ${SERVICE_LIBRARIES} ${GCOV_LIBS}) +install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${PROJECT_LIBEXECDIR}) -- cgit v1.2.3