aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt66
-rwxr-xr-xbuild.sh18
-rw-r--r--cmake/GdbusCodegen.cmake36
-rw-r--r--src/backend-dbus/CMakeLists.txt115
4 files changed, 125 insertions, 110 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9f8f026..feb332c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,43 +1,35 @@
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)
+set (PROJECT_VERSION "13.10.1")
+set (PACKAGE ${CMAKE_PROJECT_NAME})
+set (GETTEXT_PACKAGE ${CMAKE_PROJECT_NAME})
+
option (enable_tests "Build the package's automatic tests." ON)
+option (full_warnings "Full compiler warnings." 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
-#
+find_package(PkgConfig REQUIRED)
include (FindPkgConfig)
+include (GdbusCodegen)
+include (GSettings)
+
+add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" )
+add_definitions (-DGNOMELOCALEDIR=\"@CMAKE_INSTALL_PREFIX@/share/locale\")
+
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
-#
+set (CC_WARNING_ARGS " -Wall -pedantic -Wextra -Wno-missing-field-initializers")
-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
-#
+set (ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION})
add_custom_target (dist
COMMAND bzr export --root=${ARCHIVE_NAME} ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
@@ -47,25 +39,21 @@ add_custom_target (clean-coverage
add_custom_target (cppcheck COMMAND cppcheck --enable=all -q --error-exitcode=2 --inline-suppr
${CMAKE_SOURCE_DIR}/src
- ${CMAKE_SOURCE_DIR}/test)
-
-#
-#
-#
+ ${CMAKE_SOURCE_DIR}/tests)
+include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src)
+include_directories (${CMAKE_CURRENT_BINARY_DIR}/src)
-add_definitions (-DGETTEXT_PACKAGE=\"indicator-session\")
-add_definitions (-DPACKAGE_NAME=\"indicator-session\")
-add_definitions (-DGNOMELOCALEDIR=\"@CMAKE_INSTALL_PREFIX@/share/locale\")
-
-#
-# Directories
-#
+add_subdirectory (src)
+add_subdirectory (data)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
-
-add_subdirectory(src)
-add_subdirectory(data)
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 ()
add_subdirectory(tests)
endif ()
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..173ff8c
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,18 @@
+#! /bin/bash
+set -e
+
+mkdir -p build
+
+if [ -f "/usr/bin/ninja" ] ; then
+ EXTRA_ARGS="-G Ninja"
+ BUILD_COMMAND="ninja"
+else
+ BUILD_COMMAND="make"
+fi
+
+echo "Using $BUILD_COMMAND to build"
+(
+ cd build
+ cmake .. $EXTRA_ARGS -DCMAKE_INSTALL_PREFIX=../../install -Dlocal_install=ON
+ $BUILD_COMMAND
+)
diff --git a/cmake/GdbusCodegen.cmake b/cmake/GdbusCodegen.cmake
new file mode 100644
index 0000000..ddb2995
--- /dev/null
+++ b/cmake/GdbusCodegen.cmake
@@ -0,0 +1,36 @@
+cmake_minimum_required(VERSION 2.6)
+if(POLICY CMP0011)
+ cmake_policy(SET CMP0011 NEW)
+endif(POLICY CMP0011)
+
+find_program(GDBUS_CODEGEN NAMES gdbus-codegen DOC "gdbus-codegen executable")
+if(NOT GDBUS_CODEGEN)
+ message(FATAL_ERROR "Excutable gdbus-codegen not found")
+endif()
+
+macro(add_gdbus_codegen outfiles name prefix service_xml)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND "${GDBUS_CODEGEN}"
+ --interface-prefix "${prefix}"
+ --generate-c-code "${name}"
+ "${service_xml}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${ARGN} "${service_xml}"
+ )
+ list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
+endmacro(add_gdbus_codegen)
+
+macro(add_gdbus_codegen_with_namespace outfiles name prefix namespace service_xml)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND "${GDBUS_CODEGEN}"
+ --interface-prefix "${prefix}"
+ --generate-c-code "${name}"
+ --c-namespace "${namespace}"
+ "${service_xml}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${ARGN} "${service_xml}"
+ )
+ list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
+endmacro(add_gdbus_codegen_with_namespace)
diff --git a/src/backend-dbus/CMakeLists.txt b/src/backend-dbus/CMakeLists.txt
index a477cfe..dd928cc 100644
--- a/src/backend-dbus/CMakeLists.txt
+++ b/src/backend-dbus/CMakeLists.txt
@@ -1,86 +1,59 @@
-# autogenerate source code files for our DBus proxies
-function(gdbus_codegen XML_FILE INTERFACE_PREFIX SOURCE_PREFIX)
+set(BACKEND_GENERATED_SOURCES
+)
- set (SRC_C, ${SOURCE_PREFIX}.c)
- set (SRC_H, ${SOURCE_PREFIX}.h)
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-display-manager
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/display-manager.xml)
- # check for the app
- find_program (GDBUS_CODEGEN_EXECUTABLE NAMES gdbus-codegen DOC "gdbus-codegen executable")
- if(NOT GDBUS_CODEGEN_EXECUTABLE)
- message(FATAL_ERROR "Executable gdbus-codegen not found")
- endif()
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-webcredentials
+ com.canonical.indicators
+ ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.indicators.webcredentials.xml)
- # generate the code
- add_custom_command (
- OUTPUT ${SOURCE_PREFIX}.c ${SOURCE_PREFIX}.h
- COMMAND gdbus-codegen ARGS --interface-prefix ${INTERFACE_PREFIX} --generate-c-code ${SOURCE_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR}/${XML_FILE}
- DEPENDS ${XML_FILE})
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-accounts
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Accounts.xml)
+
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-user
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.Accounts.User.xml)
- # update our variables
- set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${SRC_C})
- set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${SRC_H})
- set_property (SOURCE ${SRC_C} ${SRC_H} PROPERTY GENERATED)
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-consolekit-manager
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.ConsoleKit.Manager.xml)
- # cleanup
- unset (SRC_C)
- unset (SRC_H)
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-consolekit-seat
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.ConsoleKit.Seat.xml)
-endfunction(gdbus_codegen)
-gdbus_codegen ("display-manager.xml" "org.freedesktop" "dbus-display-manager")
-gdbus_codegen ("com.canonical.indicators.webcredentials.xml" "com.canonical.indicators" "dbus-webcredentials")
-gdbus_codegen ("org.freedesktop.Accounts.xml" "org.freedesktop" "dbus-accounts")
-gdbus_codegen ("org.freedesktop.Accounts.User.xml" "org.freedesktop" "dbus-user")
-gdbus_codegen ("org.freedesktop.ConsoleKit.Manager.xml" "org.freedesktop" "dbus-consolekit-manager")
-gdbus_codegen ("org.freedesktop.ConsoleKit.Seat.xml" "org.freedesktop" "dbus-consolekit-seat")
-gdbus_codegen ("org.freedesktop.ConsoleKit.Session.xml" "org.freedesktop" "dbus-consolekit-session")
-gdbus_codegen ("org.gnome.ScreenSaver.xml" "org" "gnome-screen-saver")
-gdbus_codegen ("org.gnome.SessionManager.xml" "org" "gnome-session-manager")
-gdbus_codegen ("org.gnome.SessionManager.EndSessionDialog.xml" "org.gnome.SessionManager" "dbus-end-session-dialog")
-gdbus_codegen ("upower.xml" "org.freedesktop" "dbus-upower")
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-consolekit-session
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.ConsoleKit.Session.xml)
+
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES gnome-screen-saver
+ org
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.gnome.ScreenSaver.xml)
+
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES gnome-session-manager
+ org
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.gnome.SessionManager.xml)
+
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-end-session-dialog
+ org.gnome.SessionManager
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.gnome.SessionManager.EndSessionDialog.xml)
+
+add_gdbus_codegen (BACKEND_GENERATED_SOURCES dbus-upower
+ org.freedesktop
+ ${CMAKE_CURRENT_SOURCE_DIR}/upower.xml)
+
+set (SOURCES actions.c backend-dbus.c guest.c users.c utils.c)
# add warnings/coverage info on handwritten files
# but not the autogenerated ones...
-set_source_files_properties (actions.c
- backend-dbus.c
- guest.c
- users.c
- utils.c
+set_source_files_properties (${SOURCES}
PROPERTIES COMPILE_FLAGS " -g ${CC_WARNING_ARGS} ${GCOV_FLAGS}")
# add the bin dir to our include path s.t. our code can find the autogenerated header files
include_directories (${CMAKE_CURRENT_BINARY_DIR} ${SERVICE_INCLUDE_DIRS})
-add_library (backenddbus STATIC
- gnome-screen-saver.c
- gnome-screen-saver.h
- gnome-session-manager.c
- gnome-session-manager.h
- dbus-display-manager.c
- dbus-display-manager.h
- dbus-consolekit-manager.c
- dbus-consolekit-manager.h
- dbus-consolekit-seat.c
- dbus-consolekit-seat.h
- dbus-consolekit-session.c
- dbus-consolekit-session.h
- dbus-accounts.c
- dbus-accounts.h
- dbus-upower.c
- dbus-upower.h
- dbus-user.c
- dbus-user.h
- dbus-webcredentials.c
- dbus-webcredentials.h
- dbus-end-session-dialog.c
- dbus-end-session-dialog.h
- actions.c
- actions.h
- backend-dbus.c
- backend-dbus.h
- guest.c
- guest.h
- users.c
- users.h
- utils.c
- utils.h)
+add_library (backenddbus STATIC ${SOURCES} ${BACKEND_GENERATED_SOURCES})