aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt65
-rw-r--r--cmake/Coverage.cmake34
-rw-r--r--cmake/UseConstantBuilder.cmake19
-rw-r--r--cmake/UseGSettings.cmake42
-rw-r--r--cmake/UseGdbusCodegen.cmake35
-rw-r--r--cmake/UseGlibGeneration.cmake71
-rw-r--r--data/CMakeLists.txt50
-rw-r--r--libunity-greeter-session-broadcast/CMakeLists.txt95
-rw-r--r--service/CMakeLists.txt46
-rw-r--r--service/service.c (renamed from service/unity-greeter-session-broadcast-service.c)0
10 files changed, 457 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..47c48d4
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,65 @@
+project(unity-greeter-session-broadcast C)
+cmake_minimum_required(VERSION 2.8.9)
+
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
+
+set(PACKAGE ${CMAKE_PROJECT_NAME})
+set(GETTEXT_PACKAGE ${CMAKE_PROJECT_NAME})
+
+# Trick the H10enable_coverage script into enabling coverage by including the text below:
+# CMAKE_BUILD_TYPE coverage
+
+find_package(PkgConfig REQUIRED)
+include(GNUInstallDirs)
+include(CheckIncludeFile)
+include(CheckFunctionExists)
+include(Coverage)
+include(UseGlibGeneration)
+include(UseGdbusCodegen)
+include(UseConstantBuilder)
+include(UseGSettings)
+
+# Workaround for libexecdir on debian
+if (EXISTS "/etc/debian_version")
+ set(CMAKE_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBDIR})
+ set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}")
+endif()
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
+
+pkg_check_modules(GLIB2 REQUIRED glib-2.0)
+include_directories(${GLIB2_INCLUDE_DIRS})
+
+pkg_check_modules(GOBJECT2 REQUIRED gobject-2.0)
+include_directories(${GOBJECT2_INCLUDE_DIRS})
+
+pkg_check_modules(GIO2 REQUIRED gio-2.0)
+include_directories(${GIO2_INCLUDE_DIRS})
+
+if(${LOCAL_INSTALL})
+ set(DBUSSERVICEDIR "${CMAKE_INSTALL_DATADIR}/dbus-1/services/")
+else()
+ EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS dbus-1 --variable session_bus_services_dir OUTPUT_VARIABLE DBUSSERVICEDIR )
+endif()
+message("Installing DBus services to ${DBUSSERVICEDIR}")
+
+if(${LOCAL_INSTALL})
+ set(DBUSIFACEDIR "${CMAKE_INSTALL_DATADIR}/dbus-1/interfaces/")
+else()
+ EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS dbus-1 --variable interfaces_dir OUTPUT_VARIABLE DBUSIFACEDIR )
+endif()
+message("Installing DBus interfaces to ${DBUSIFACEDIR}")
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -fPIC")
+
+add_subdirectory(data)
+add_subdirectory(service)
+add_subdirectory(libunity-greeter-session-broadcast)
+
+# TODO
+# enable_testing()
+# add_subdirectory(tests)
+
diff --git a/cmake/Coverage.cmake b/cmake/Coverage.cmake
new file mode 100644
index 0000000..160dac2
--- /dev/null
+++ b/cmake/Coverage.cmake
@@ -0,0 +1,34 @@
+if (CMAKE_BUILD_TYPE MATCHES coverage)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
+
+ 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.*" --exclude="obj.*" -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 "${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
+ )
+ endif()
+ endif()
+endif()
diff --git a/cmake/UseConstantBuilder.cmake b/cmake/UseConstantBuilder.cmake
new file mode 100644
index 0000000..06c8d05
--- /dev/null
+++ b/cmake/UseConstantBuilder.cmake
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.6)
+if(POLICY CMP0011)
+ cmake_policy(SET CMP0011 NEW)
+endif(POLICY CMP0011)
+
+macro(add_constant_template outfiles name const_name input)
+ set(file_target "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
+ add_custom_command(
+ OUTPUT ${file_target}
+ COMMAND ${CMAKE_COMMAND}
+ "-Dname=${name}"
+ "-Dfile_target=${file_target}"
+ "-Dconst_name=${const_name}"
+ "-Dinput=${input}"
+ -P "${CMAKE_SOURCE_DIR}/cmake/ConstantBuilderTemplates.cmake"
+ DEPENDS "${CMAKE_SOURCE_DIR}/cmake/ConstantBuilderTemplates.cmake" "${input}"
+ )
+ list(APPEND ${outfiles} "${file_target}")
+endmacro(add_constant_template)
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()
diff --git a/cmake/UseGdbusCodegen.cmake b/cmake/UseGdbusCodegen.cmake
new file mode 100644
index 0000000..aa23ca3
--- /dev/null
+++ b/cmake/UseGdbusCodegen.cmake
@@ -0,0 +1,35 @@
+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()
+
+function(add_gdbus_codegen)
+ set(_one_value OUTFILES NAME PREFIX NAMESPACE SERVICE_XML)
+ set(_multi_value DEPENDS)
+ cmake_parse_arguments (arg "" "${_one_value}" "${_multi_value}" ${ARGN})
+
+ if(arg_PREFIX)
+ set(PREFIX --interface-prefix ${arg_PREFIX})
+ endif()
+
+ if(arg_NAMESPACE)
+ set(NAMESPACE --c-namespace ${arg_NAMESPACE})
+ endif()
+
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.h" "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.c"
+ COMMAND "${GDBUS_CODEGEN}"
+ --generate-c-code "${arg_NAME}"
+ ${PREFIX}
+ ${NAMESPACE}
+ "${arg_SERVICE_XML}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${arg_DEPENDS} "${arg_SERVICE_XML}"
+ )
+ set(${arg_OUTFILES} ${${arg_OUTFILES}} "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.c" PARENT_SCOPE)
+endfunction(add_gdbus_codegen)
diff --git a/cmake/UseGlibGeneration.cmake b/cmake/UseGlibGeneration.cmake
new file mode 100644
index 0000000..67e34b9
--- /dev/null
+++ b/cmake/UseGlibGeneration.cmake
@@ -0,0 +1,71 @@
+cmake_minimum_required(VERSION 2.6)
+if(POLICY CMP0011)
+ cmake_policy(SET CMP0011 NEW)
+endif(POLICY CMP0011)
+
+find_program(GLIB_MKENUMS glib-mkenums)
+find_program(GLIB_GENMARSHAL glib-genmarshal)
+
+macro(add_glib_marshal outfiles name prefix otherinclude)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ COMMAND ${GLIB_GENMARSHAL} --header "--prefix=${prefix}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
+ > "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
+ )
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND echo "\\#include \\\"${otherinclude}\\\"" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND echo "\\#include \\\"glib-object.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND echo "\\#include \\\"${name}.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND ${GLIB_GENMARSHAL} --body "--prefix=${prefix}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
+ >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
+ "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ )
+ list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
+endmacro(add_glib_marshal)
+
+macro(add_glib_enumtypes_t outfiles name htemplate ctemplate)
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ COMMAND ${GLIB_MKENUMS}
+ --template "${htemplate}"
+ ${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${ARGN} "${htemplate}"
+ )
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ COMMAND ${GLIB_MKENUMS}
+ --template "${ctemplate}"
+ ${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${ARGN} ${ctemplate}
+ "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
+ )
+ list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
+endmacro(add_glib_enumtypes_t)
+
+macro(add_glib_enumtypes outfiles name namespace includeguard)
+ set(htemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.h.template")
+ set(ctemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.c.template")
+
+ # Write the .h template
+ add_custom_command(
+ OUTPUT ${htemplate} ${ctemplate}
+ COMMAND ${CMAKE_COMMAND}
+ "-Dctemplate=${ctemplate}"
+ "-Dhtemplate=${htemplate}"
+ "-Dname=${name}"
+ "-Dnamespace=${namespace}"
+ "-Dincludeguard=${includeguard}"
+ "\"-Dheaders=${ARGN}\""
+ -P "${CMAKE_SOURCE_DIR}/cmake/GlibGenerationTemplates.cmake"
+ DEPENDS "${CMAKE_SOURCE_DIR}/cmake/GlibGenerationTemplates.cmake" ${headers}
+ )
+
+ add_glib_enumtypes_t(${outfiles} ${name} ${htemplate} ${ctemplate} ${ARGN})
+endmacro(add_glib_enumtypes)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
new file mode 100644
index 0000000..b784adb
--- /dev/null
+++ b/data/CMakeLists.txt
@@ -0,0 +1,50 @@
+
+###########################
+# Dbus Interfaces
+###########################
+
+install(
+FILES
+com.canonical.Unity.Greeter.Broadcast.xml
+DESTINATION ${DBUSIFACEDIR}
+)
+
+###########################
+# Dbus Services
+###########################
+
+set(BROADCAST_SERVICE
+"${CMAKE_CURRENT_BINARY_DIR}/com.canonical.Unity.Greeter.Broadcast.service"
+)
+
+set(pkglibexecdir "${CMAKE_INSTALL_FULL_LIBEXECDIR}/unity-greeter-session-broadcast")
+configure_file("com.canonical.Unity.Greeter.Broadcast.service.in"
+ "${BROADCAST_SERVICE}"
+ @ONLY
+)
+
+install(
+FILES
+"${BROADCAST_SERVICE}"
+DESTINATION ${DBUSSERVICEDIR}
+)
+
+###########################
+# Upstart Job
+###########################
+
+set(SESSION_UPSTART
+"${CMAKE_CURRENT_SOURCE_DIR}/unity-greeter-session-broadcast-session.conf"
+)
+
+install(
+FILES
+"${SESSION_UPSTART}"
+DESTINATION "/usr/share/upstart/sessions"
+)
+
+###########################
+# GSettings
+###########################
+
+add_schema ("com.canonical.Unity.Greeter.Broadcast.gschema.xml")
diff --git a/libunity-greeter-session-broadcast/CMakeLists.txt b/libunity-greeter-session-broadcast/CMakeLists.txt
new file mode 100644
index 0000000..7db1f6d
--- /dev/null
+++ b/libunity-greeter-session-broadcast/CMakeLists.txt
@@ -0,0 +1,95 @@
+
+###########################
+# Version Information
+###########################
+
+set(API_VERSION 1)
+set(ABI_VERSION 1)
+
+###########################
+# Generated Lib
+###########################
+
+set(GENERATED_HEADERS
+service-iface.h
+)
+
+set(GENERATED_SOURCES
+service-iface.c
+)
+
+add_gdbus_codegen(
+OUTFILES GENERATED_SOURCES
+NAME service-iface
+PREFIX com.canonical.Unity.Greeter.Broadcast.
+NAMESPACE _ServiceIface
+SERVICE_XML ${CMAKE_CURRENT_SOURCE_DIR}/../data/com.canonical.Unity.Greeter.Broadcast.xml
+)
+
+add_library(generated STATIC ${GENERATED_SOURCES})
+
+target_link_libraries(generated
+${GLIB2_LIBRARIES}
+${GOBJECT2_LIBRARIES}
+${GIO2_LIBRARIES}
+)
+
+###########################
+# Lib
+###########################
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+
+set(BROADCAST_HEADERS
+unity-greeter-session-broadcast.h
+)
+
+set(BROADCAST_SOURCES
+unity-greeter-session-broadcast.c
+)
+
+add_library(broadcast SHARED ${BROADCAST_SOURCES})
+
+set_target_properties(broadcast PROPERTIES
+ VERSION ${API_VERSION}.0.0
+ SOVERSION ${ABI_VERSION}
+ OUTPUT_NAME "unity-greeter-session-broadcast"
+)
+
+target_link_libraries(broadcast
+generated
+${GLIB2_LIBRARIES}
+${GOBJECT2_LIBRARIES}
+-Wl,--no-undefined
+)
+
+###########################
+# Pkg Config
+###########################
+
+set(BROADCAST_PC "unity-greeter-session-broadcast-${API_VERSION}.pc")
+set(apiversion "${API_VERSION}")
+set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
+set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+set(VERSION "${ABI_VERSION}")
+
+configure_file("unity-greeter-session-broadcast.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${BROADCAST_PC}" @ONLY)
+
+###########################
+# Installation
+###########################
+
+install(
+ FILES ${BROADCAST_HEADERS}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libunity-greeter-session-broadcast-${API_VERSION}"
+)
+
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${BROADCAST_PC}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
+)
+
+install(
+ TARGETS broadcast
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt
new file mode 100644
index 0000000..12caadc
--- /dev/null
+++ b/service/CMakeLists.txt
@@ -0,0 +1,46 @@
+
+###########################
+# Generated Lib
+###########################
+
+set(SERVICE_GENERATED_HEADERS
+service-iface.h
+)
+
+set(SERVICE_GENERATED_SOURCES
+service-iface.c
+)
+
+add_gdbus_codegen(
+OUTFILES SERVICE_GENERATED_SOURCES
+NAME service-iface
+PREFIX com.canonical.Unity.Greeter.Broadcast.
+NAMESPACE ServiceIface
+SERVICE_XML ${CMAKE_CURRENT_SOURCE_DIR}/../data/com.canonical.Unity.Greeter.Broadcast.xml
+)
+
+add_library(service-generated STATIC ${HUD_SERVICE_GENERATED_SOURCES})
+
+target_link_libraries(service-generated
+${GLIB2_LIBRARIES}
+${GOBJECT2_LIBRARIES}
+)
+
+###########################
+# Service Executable
+###########################
+
+add_executable(service-exec service.c)
+
+set_target_properties(service-exec PROPERTIES OUTPUT_NAME "unity-greeter-session-broadcast-service")
+
+target_link_libraries(service-exec service-generated)
+
+###########################
+# Installation
+###########################
+
+install(
+ TARGETS service-exec
+ RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/unity-greeter-session-broadcast"
+)
diff --git a/service/unity-greeter-session-broadcast-service.c b/service/service.c
index 7cd5cca..7cd5cca 100644
--- a/service/unity-greeter-session-broadcast-service.c
+++ b/service/service.c