aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-18 21:33:19 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-07-18 21:33:19 +0000
commit512426b01bfa72a3c0d21b1ffbefd46bd7ebe306 (patch)
treee897bb966a0530f67fb9cfd74e8cc391d6748e8b /cmake
parent2d06cbb066f9ae0a0a49d5d260ebe28bb17311fc (diff)
parent9f1ebe8f6c412ab18bdf32bf949fc00152d9671b (diff)
downloadayatana-indicator-power-512426b01bfa72a3c0d21b1ffbefd46bd7ebe306.tar.gz
ayatana-indicator-power-512426b01bfa72a3c0d21b1ffbefd46bd7ebe306.tar.bz2
ayatana-indicator-power-512426b01bfa72a3c0d21b1ffbefd46bd7ebe306.zip
Switch from automake/autoconf to CMake.
Approved by: Ted Gould, PS Jenkins bot
Diffstat (limited to 'cmake')
-rw-r--r--cmake/GCov.cmake51
-rw-r--r--cmake/GdbusCodegen.cmake36
-rw-r--r--cmake/Translations.cmake41
-rw-r--r--cmake/UseGSettings.cmake23
4 files changed, 151 insertions, 0 deletions
diff --git a/cmake/GCov.cmake b/cmake/GCov.cmake
new file mode 100644
index 0000000..81c0c40
--- /dev/null
+++ b/cmake/GCov.cmake
@@ -0,0 +1,51 @@
+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 "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info
+ COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-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/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/cmake/Translations.cmake b/cmake/Translations.cmake
new file mode 100644
index 0000000..d41f04e
--- /dev/null
+++ b/cmake/Translations.cmake
@@ -0,0 +1,41 @@
+# Translations.cmake, CMake macros written for Marlin, feel free to re-use them
+
+macro(add_translations_directory NLS_PACKAGE)
+ add_custom_target (i18n ALL)
+ find_program (MSGFMT_EXECUTABLE msgfmt)
+ file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po)
+ foreach (PO_INPUT ${PO_FILES})
+ get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE)
+ set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo)
+ add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT})
+
+ install (FILES ${MO_OUTPUT} DESTINATION
+ ${CMAKE_INSTALL_LOCALEDIR}/${PO_INPUT_BASE}/LC_MESSAGES
+ RENAME ${NLS_PACKAGE}.mo)
+ endforeach (PO_INPUT ${PO_FILES})
+endmacro(add_translations_directory)
+
+
+macro(add_translations_catalog NLS_PACKAGE)
+ add_custom_target (pot COMMENT “Building translation catalog.”)
+ find_program (XGETTEXT_EXECUTABLE xgettext)
+
+
+ set(C_SOURCE "")
+
+ foreach(FILES_INPUT ${ARGN})
+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c)
+ foreach(C_FILE ${SOURCE_FILES})
+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
+ endforeach()
+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala)
+ foreach(C_FILE ${SOURCE_FILES})
+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
+ endforeach()
+ endforeach()
+
+ add_custom_command (TARGET pot COMMAND
+ ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
+ ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8
+ )
+endmacro()
diff --git a/cmake/UseGSettings.cmake b/cmake/UseGSettings.cmake
new file mode 100644
index 0000000..3b61523
--- /dev/null
+++ b/cmake/UseGSettings.cmake
@@ -0,0 +1,23 @@
+# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them.
+
+macro(add_schema SCHEMA_NAME)
+
+ set(PKG_CONFIG_EXECUTABLE pkg-config)
+ set(GSETTINGS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/glib-2.0/schemas")
+
+ # Run the validator and error if it fails
+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_compile_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process (COMMAND ${_glib_compile_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_DIR} is the GSettings install dir")
+ install (FILES ${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
+
+ install (CODE "message (STATUS \"Compiling GSettings schemas\")")
+ install (CODE "execute_process (COMMAND ${_glib_compile_schemas} ${GSETTINGS_DIR})")
+endmacro()
+