aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt71
-rw-r--r--cmake/FindIntltool.cmake23
-rw-r--r--cmake/GCov.cmake50
-rw-r--r--cmake/GSettings.cmake108
-rw-r--r--cmake/Gettext.cmake179
5 files changed, 431 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..9f8f026
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,71 @@
+project (indicator-session C CXX)
+set (PROJECT_VERSION "13.10.1")
+cmake_minimum_required (VERSION 2.8.9)
+list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+
+option (full_warnings "Full compiler warnings." ON)
+option (enable_tests "Build the package's automatic tests." ON)
+option (enable_lcov "Generate lcov code coverage reports." ON)
+
+set (ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
+set (CC_WARNING_ARGS " -Wall -pedantic -Wextra -Wno-missing-field-initializers")
+
+#
+# Check for glib/gio
+#
+
+include (FindPkgConfig)
+pkg_check_modules (SERVICE REQUIRED
+ glib-2.0>=2.35.4
+ gio-unix-2.0>=2.25.11)
+include_directories (${SERVICE_INCLUDE_DIRS})
+
+#
+# Testing / Coverage
+#
+
+if (${enable_tests})
+ set (GTEST_SOURCE_DIR /usr/src/gtest/src)
+ set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..)
+ set (GTEST_LIBS -lpthread)
+ enable_testing ()
+ if (${enable_lcov})
+ include(cmake/GCov.cmake)
+ endif ()
+endif ()
+
+#
+# Custom Targets
+#
+
+add_custom_target (dist
+ COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+add_custom_target (clean-coverage
+ COMMAND find ${CMAKE_BINARY_DIR} -name '*.gcda' | xargs rm -f)
+
+add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/test)
+
+#
+#
+#
+
+
+add_definitions (-DGETTEXT_PACKAGE=\"indicator-session\")
+add_definitions (-DPACKAGE_NAME=\"indicator-session\")
+add_definitions (-DGNOMELOCALEDIR=\"@CMAKE_INSTALL_PREFIX@/share/locale\")
+
+#
+# Directories
+#
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
+
+add_subdirectory(src)
+add_subdirectory(data)
+if (${enable_tests})
+ add_subdirectory(tests)
+endif ()
diff --git a/cmake/FindIntltool.cmake b/cmake/FindIntltool.cmake
new file mode 100644
index 0000000..45318c4
--- /dev/null
+++ b/cmake/FindIntltool.cmake
@@ -0,0 +1,23 @@
+# FindIntltool.cmake
+#
+# Jim Nelson <jim@yorba.org>
+# Copyright 2012 Yorba Foundation
+
+find_program (INTLTOOL_MERGE_EXECUTABLE intltool-merge)
+
+if (INTLTOOL_MERGE_EXECUTABLE)
+ set (INTLTOOL_MERGE_FOUND TRUE)
+else (INTLTOOL_MERGE_EXECUTABLE)
+ set (INTLTOOL_MERGE_FOUND FALSE)
+endif (INTLTOOL_MERGE_EXECUTABLE)
+
+if (INTLTOOL_MERGE_FOUND)
+ macro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir)
+ add_custom_target (geary.desktop ALL
+ ${INTLTOOL_MERGE_EXECUTABLE} --desktop-style ${CMAKE_SOURCE_DIR}/${po_dir}
+ ${CMAKE_CURRENT_SOURCE_DIR}/${desktop_id}.desktop.in ${desktop_id}.desktop
+ )
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/geary.desktop DESTINATION /usr/share/applications)
+ endmacro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir)
+endif (INTLTOOL_MERGE_FOUND)
+
diff --git a/cmake/GCov.cmake b/cmake/GCov.cmake
new file mode 100644
index 0000000..8df10ee
--- /dev/null
+++ b/cmake/GCov.cmake
@@ -0,0 +1,50 @@
+if (CMAKE_BUILD_TYPE MATCHES coverage)
+ set(GCOV_FLAGS "${GCOV_FLAGS} --coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}")
+ set(GCOV_LIBS ${GCOV_LIBS} gcov)
+
+ find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
+ if (NOT GCOVR_EXECUTABLE)
+ message(STATUS "Gcovr binary was not found, can not generate XML coverage info.")
+ else ()
+ message(STATUS "Gcovr found, can generate XML coverage info.")
+ add_custom_target (coverage-xml
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}"
+ --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml)
+ endif()
+
+ find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin")
+ find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT})
+ if (NOT LCOV_EXECUTABLE)
+ message(STATUS "Lcov binary was not found, can not generate HTML coverage info.")
+ else ()
+ if(NOT GENHTML_EXECUTABLE)
+ message(STATUS "Genthml binary not found, can not generate HTML coverage info.")
+ else()
+ message(STATUS "Lcov and genhtml found, can generate HTML coverage info.")
+ add_custom_target (coverage-html
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose
+ COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info
+ COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details dconf-lcov.info
+ COMMAND ${CMAKE_COMMAND} -E echo ""
+ COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html"
+ COMMAND ${CMAKE_COMMAND} -E echo "")
+ #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum
+ #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info
+ #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
+ #)
+ endif()
+ endif()
+endif()
+
+
+ #$(MAKE) $(AM_MAKEFLAGS) check
+ #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info
+ #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info
+ #@echo
+ #@echo " file://$(abs_top_builddir)/lcov-html/index.html"
+ #@echo
diff --git a/cmake/GSettings.cmake b/cmake/GSettings.cmake
new file mode 100644
index 0000000..5902baa
--- /dev/null
+++ b/cmake/GSettings.cmake
@@ -0,0 +1,108 @@
+# 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/Gettext.cmake b/cmake/Gettext.cmake
new file mode 100644
index 0000000..9be4742
--- /dev/null
+++ b/cmake/Gettext.cmake
@@ -0,0 +1,179 @@
+# Gettext support: Create/Update pot file and
+#
+# To use: INCLUDE(Gettext)
+#
+# Most of the gettext support code is from FindGettext.cmake of cmake,
+# but it is included here because:
+#
+# 1. Some system like RHEL5 does not have FindGettext.cmake
+# 2. Bug of GETTEXT_CREATE_TRANSLATIONS make it unable to be include in 'All'
+# 3. It does not support xgettext
+#
+#===================================================================
+# Constants:
+# XGETTEXT_OPTIONS_DEFAULT: Default xgettext option:
+#===================================================================
+# Variables:
+# XGETTEXT_OPTIONS: Options pass to xgettext
+# Default: XGETTEXT_OPTIONS_DEFAULT
+# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
+# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
+# GETTEXT_FOUND: True if gettext has been found.
+# XGETTEXT_EXECUTABLE: the full path to the xgettext.
+# XGETTEXT_FOUND: True if xgettext has been found.
+#
+#===================================================================
+# Macros:
+# GETTEXT_CREATE_POT(potFile
+# [OPTION xgettext_options]
+# SRC list_of_source_file_that_contains_msgid
+# )
+#
+# Generate .pot file.
+# OPTION xgettext_options: Override XGETTEXT_OPTIONS
+#
+# * Produced targets: pot_file
+#
+#-------------------------------------------------------------------
+# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] locale1 ... localeN
+# [COMMENT comment] )
+#
+# This will create a target "translations" which will convert the
+# given input po files into the binary output mo file. If the
+# ALL option is used, the translations will also be created when
+# building the default target.
+#
+# * Produced targets: translations
+#-------------------------------------------------------------------
+
+FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
+FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
+FIND_PROGRAM(GETTEXT_MSGCAT_EXECUTABLE msgcat)
+FIND_PROGRAM(XGETTEXT_EXECUTABLE xgettext)
+
+SET(XGETTEXT_OPTIONS_DEFAULT
+ --language=C --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 -s
+ --escape --add-comments="/" --package-name=${PROJECT_NAME} --package-version=${VERSION})
+
+IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGCAT_EXECUTABLE)
+ SET(GETTEXT_FOUND TRUE)
+ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE)
+ SET(GETTEXT_FOUND FALSE)
+ IF (GetText_REQUIRED)
+ MESSAGE(FATAL_ERROR "GetText not found")
+ ENDIF (GetText_REQUIRED)
+ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE AND GETTEXT_MSGCAT_EXECUTABLE)
+
+IF(XGETTEXT_EXECUTABLE)
+ SET(XGETTEXT_FOUND TRUE)
+ELSE(XGETTEXT_EXECUTABLE)
+ MESSAGE(STATUS "xgettext not found.")
+ SET(XGETTTEXT_FOUND FALSE)
+ENDIF(XGETTEXT_EXECUTABLE)
+
+IF(NOT DEFINED XGETTEXT_OPTIONS)
+ SET(XGETTEXT_OPTIONS ${XGETTEXT_OPTIONS_DEFAULT})
+ENDIF(NOT DEFINED XGETTEXT_OPTIONS)
+
+IF(XGETTEXT_FOUND)
+ MACRO(GETTEXT_CREATE_POT _potFile _pot_options )
+ SET(_xgettext_options_list)
+ SET(_src_list)
+ SET(_src_list_abs)
+ SET(_glade_list)
+ SET(_glade_list_abs)
+ SET(_stage "SRC")
+ FOREACH(_pot_option ${_pot_options} ${ARGN})
+ IF(_pot_option STREQUAL "OPTION")
+ SET(_stage "OPTION")
+ ELSEIF(_pot_option STREQUAL "SRC")
+ SET(_stage "SRC")
+ ELSEIF(_pot_option STREQUAL "GLADE")
+ SET(_stage "GLADE")
+ ELSE(_pot_option STREQUAL "OPTION")
+ IF(_stage STREQUAL "OPTION")
+ SET(_xgettext_options_list ${_xgettext_options_list} ${_pot_option})
+ ELSEIF(_stage STREQUAL "GLADE")
+ FILE(RELATIVE_PATH _relFile ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/${_pot_option})
+ GET_FILENAME_COMPONENT(_absFile ${_pot_option} ABSOLUTE)
+ SET(_glade_list ${_glade_list} ${_relFile})
+ SET(_glade_list_abs ${_glade_list_abs} ${_absFile})
+ ELSEIF(_stage STREQUAL "SRC")
+ FILE(RELATIVE_PATH _relFile ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_pot_option})
+ GET_FILENAME_COMPONENT(_absFile ${_pot_option} ABSOLUTE)
+ SET(_src_list ${_src_list} ${_relFile})
+ SET(_src_list_abs ${_src_list_abs} ${_absFile})
+ ENDIF(_stage STREQUAL "OPTION")
+ ENDIF(_pot_option STREQUAL "OPTION")
+ ENDFOREACH(_pot_option ${_pot_options} ${ARGN})
+
+ IF (_xgettext_options_list)
+ SET(_xgettext_options ${_xgettext_options_list})
+ ELSE(_xgettext_options_list)
+ SET(_xgettext_options ${XGETTEXT_OPTIONS})
+ ENDIF(_xgettext_options_list)
+
+ #MESSAGE("${XGETTEXT_EXECUTABLE} ${_xgettext_options_list} -o ${_potFile} ${_src_list}")
+ ADD_CUSTOM_COMMAND(OUTPUT pot_file
+ COMMAND ${XGETTEXT_EXECUTABLE} ${_xgettext_options} -o ${_potFile} ${_src_list}
+ DEPENDS ${_src_list_abs} ${GLADE_FILES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ ADD_CUSTOM_TARGET(pot_file
+ COMMAND ${XGETTEXT_EXECUTABLE} ${_xgettext_options_list} -o _source.pot ${_src_list}
+ COMMAND ${XGETTEXT_EXECUTABLE} --language=Glade --omit-header -o _glade.pot ${_glade_list}
+ COMMAND ${GETTEXT_MSGCAT_EXECUTABLE} -o ${_potFile} --use-first _source.pot _glade.pot
+ DEPENDS ${_src_list_abs}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Extract translatable messages to ${_potFile}"
+ )
+ ENDMACRO(GETTEXT_CREATE_POT _potFile _pot_options)
+
+
+ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstLang)
+ SET(_gmoFiles)
+ GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
+ GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
+
+ SET(_addToAll)
+ SET(_is_comment FALSE)
+
+ FOREACH (_currentLang ${_firstLang} ${ARGN})
+ IF(_currentLang STREQUAL "ALL")
+ SET(_addToAll "ALL")
+ ELSEIF(_currentLang STREQUAL "COMMENT")
+ SET(_is_comment TRUE)
+ ELSEIF(_is_comment)
+ SET(_is_comment FALSE)
+ SET(_comment ${_currentLang})
+ ELSE()
+ SET(_lang ${_currentLang})
+ GET_FILENAME_COMPONENT(_absFile ${_currentLang}.po ABSOLUTE)
+ GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH)
+ SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.mo)
+
+ #MESSAGE("_absFile=${_absFile} _abs_PATH=${_abs_PATH} _lang=${_lang} curr_bin=${CMAKE_CURRENT_BINARY_DIR}")
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${_gmoFile}
+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
+ DEPENDS ${_absPotFile} ${_absFile}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
+ SET(_gmoFiles ${_gmoFiles} ${_gmoFile})
+ ENDIF()
+ ENDFOREACH (_currentLang )
+
+ IF(DEFINED _comment)
+ ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles} COMMENT ${_comment})
+ ELSE(DEFINED _comment)
+ ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
+ ENDIF(DEFINED _comment)
+ ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
+ENDIF(XGETTEXT_FOUND)
+
+
+