diff options
-rw-r--r-- | CMakeLists.txt | 74 | ||||
-rw-r--r-- | bindings/CMakeLists.txt | 2 | ||||
-rw-r--r-- | bindings/mono/CMakeLists.txt | 203 | ||||
-rw-r--r-- | bindings/mono/examples/CMakeLists.txt | 20 | ||||
-rw-r--r-- | bindings/vala/CMakeLists.txt | 29 | ||||
-rw-r--r-- | bindings/vala/examples/CMakeLists.txt | 27 | ||||
-rw-r--r-- | cmake/FindGObjectIntrospection.cmake | 61 | ||||
-rw-r--r-- | cmake/FindVala.cmake | 57 | ||||
-rw-r--r-- | cmake/UseGObjectIntrospection.cmake | 100 | ||||
-rw-r--r-- | cmake/UseVala.cmake | 241 | ||||
-rw-r--r-- | docs/CMakeLists.txt | 1 | ||||
-rw-r--r-- | docs/reference/CMakeLists.txt | 233 | ||||
-rw-r--r-- | docs/reference/scangobj.sh.in | 1 | ||||
-rw-r--r-- | example/CMakeLists.txt | 37 | ||||
-rw-r--r-- | src/CMakeLists.txt | 166 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 184 |
16 files changed, 1436 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c28eab1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.13) +project(libayatana-appindicator C) + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) +endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) + +option(ENABLE_TESTS "Enable all tests and checks" OFF) +option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF) + +# Check for prerequisites + +set(DEPS glib-2.0>=2.58 ayatana-indicator3-0.4>=0.8.4 gtk+-3.0>=3.24 dbusmenu-gtk3-0.4) + +if(ENABLE_COVERAGE) + set(ENABLE_TESTS ON) + set(CMAKE_BUILD_TYPE "Coverage") +else() + set(CMAKE_BUILD_TYPE "Release") +endif() + +if(ENABLE_TESTS) + set(DEPS ${DEPS} dbus-1>=1.12 dbus-glib-1>=0.82) +endif() + +find_package(PkgConfig REQUIRED) +pkg_check_modules(PROJECT_DEPS REQUIRED ${DEPS}) + +# Set global variables + +include(GNUInstallDirs) +set(PROJECT_VERSION "0.5.90") +set(PROJECT_NAME "libayatana-appindicator") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Weverything") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-c++98-compat -Wno-padded") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-documentation") + +else() + + set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall") + +endif() + +# Make everything + +add_subdirectory(src) +add_subdirectory(bindings) +add_subdirectory(docs) + +if (ENABLE_TESTS) + + include(CTest) + enable_testing() + add_subdirectory(tests) + add_subdirectory(example) + + if(ENABLE_COVERAGE) + + find_package(CoverageReport) + ENABLE_COVERAGE_REPORT(TARGETS "ayatana-appindicator3" TESTS "test-libappindicator" "test-libappindicator-dbus-client" "test-libappindicator-dbus-server" "test-libappindicator-status-client" "test-libappindicator-status-server" "test-libappindicator-fallback-item" "test-libappindicator-fallback-watcher" FILTER /usr/include ${CMAKE_BINARY_DIR}/*) + + endif() + +endif() + +# Display config info + +message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Unit tests: ${ENABLE_TESTS}") diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt new file mode 100644 index 0000000..b4fa5de --- /dev/null +++ b/bindings/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(vala) +add_subdirectory(mono) diff --git a/bindings/mono/CMakeLists.txt b/bindings/mono/CMakeLists.txt new file mode 100644 index 0000000..2a9d990 --- /dev/null +++ b/bindings/mono/CMakeLists.txt @@ -0,0 +1,203 @@ +# ayatana-appindicator-sharp3-0.1.pc + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp3-0.1.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp3-0.1.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp3-0.1.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + +# ayatana-appindicator-sharp.dll.config + +file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp.dll.config" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp.dll.config" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") + +# app-indicator.sources.xml + +file(RELATIVE_PATH REL_BIN ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}) +file(RELATIVE_PATH REL_SRC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/app-indicator.sources.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/app-indicator.sources.xml" @ONLY) + +# libayatana-appindicator-api.raw + +find_program(GAPI3_PARSER gapi3-parser) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.raw" + DEPENDS "src" "${CMAKE_CURRENT_BINARY_DIR}/app-indicator.sources.xml" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${GAPI3_PARSER} + "${CMAKE_CURRENT_BINARY_DIR}/app-indicator.sources.xml" +) + +# libayatana-appindicator-api.middle + +find_program(GAPI3_FIXUP gapi3-fixup) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.middle" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.raw" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${CMAKE_COMMAND} + -E copy + "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.raw" + "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.middle" + COMMAND + ${GAPI3_FIXUP} + --api=libayatana-appindicator-api.middle + --metadata="${CMAKE_CURRENT_SOURCE_DIR}/libayatana-appindicator-api.metadata" +) + +# libayatana-appindicator-api.xml + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.xml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.middle" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + COMMAND + sed + -e "s|PROP_ID_S|id|" + -e "s|PROP_STATUS_S|Status|" + -e "s|PROP_STATUS_S|status|" + -e "s|PROP_CATEGORY_S|Category|" + -e "s|PROP_CATEGORY_S|category|" + -e "s|PROP_ICON_NAME_S|icon-name|" + -e "s|PROP_ICON_DESC_S|IconDesc|" + -e "s|PROP_ICON_DESC_S|icon-desc|" + -e "s|PROP_ATTENTION_ICON_NAME_S|AttentionIconName|" + -e "s|PROP_ATTENTION_ICON_NAME_S|attention-icon-name|" + -e "s|PROP_ATTENTION_ICON_DESC_S|AttentionIconDesc|" + -e "s|PROP_ATTENTION_ICON_DESC_S|attention-icon-desc|" + -e "s|PROP_ICON_THEME_PATH_S|icon-theme-path|" + -e "s|PROP_MENU_S|menu|" + -e "s|PROP_CONNECTED_S|connected|" + -e "s|PROP_LABEL_S|label|" + -e "s|PROP_LABEL_GUIDE_S|label-guide|" + -e "s|PROP_ORDERING_INDEX_S|ordering-index|" + -e "s|PROP_DBUS_MENU_SERVER_S|DbusMenuServer|" + -e "s|PROP_DBUS_MENU_SERVER_S|dbus-menu-server|" + -e "s|PROP_TITLE_S|Title|" + -e "s|PROP_TITLE_S|title|" + "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.middle" > "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.xml" +) + +# AppIndicatorCategory.cs +# NewAttentionIconHandler.cs +# NewStatusHandler.cs +# AppIndicatorStatus.cs +# NewIconHandler.cs +# ObjectManager.cs +# ApplicationIndicator.cs +# NewIconThemePathHandler.cs +# ScrollEventHandler.cs +# ConnectionChangedHandler.cs +# NewLabelHandler.cs + +pkg_check_modules(GTK_SHARP_3_0 REQUIRED gtk-sharp-3.0>=2.99) +string(REPLACE ":" ";-I:" GTK_SHARP_3_0_INCLUDE_DIRS ${GTK_SHARP_3_0_INCLUDE_DIRS}) +find_program(GAPI3_CODEGEN gapi3-codegen) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/GtkSharp/ObjectManager.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/AppIndicatorCategory.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewAttentionIconHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewStatusHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/AppIndicatorStatus.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewIconHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ApplicationIndicator.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewIconThemePathHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ScrollEventHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ConnectionChangedHandler.cs" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewLabelHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-api.xml" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${GAPI3_CODEGEN} + --generate libayatana-appindicator-api.xml + --outdir=${CMAKE_CURRENT_BINARY_DIR} + --assembly-name=ayatana-appindicator-sharp + ${GTK_SHARP_3_0_INCLUDE_DIRS} +) + +# ayatana-appindicator-sharp.dll + +pkg_check_modules(MONO REQUIRED mono>=5.18) +find_program(MCS mcs) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp.dll" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/GtkSharp/ObjectManager.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/AppIndicatorCategory.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewAttentionIconHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewStatusHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/AppIndicatorStatus.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewIconHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ApplicationIndicator.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewIconThemePathHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ScrollEventHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/ConnectionChangedHandler.cs" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/NewLabelHandler.cs" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${MCS} + -keyfile:"${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp.snk" + -nowarn:0169,0612,0618 + -unsafe + -out:"${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp.dll" + -target:library + ${GTK_SHARP_3_0_LDFLAGS} "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator/*.cs" "${CMAKE_CURRENT_BINARY_DIR}/GtkSharp/ObjectManager.cs" "${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cs" "${CMAKE_CURRENT_SOURCE_DIR}/ApplicationIndicatorCustom.cs" +) + +find_program(GACUTIL gacutil) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp.dll" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") +install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${GACUTIL} -i ${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp.dll -package ayatana-appindicator-sharp -root ${CMAKE_INSTALL_FULL_LIBDIR})") + +# policy.0.0.ayatana-appindicator-sharp.config + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/policy.0.0.ayatana-appindicator-sharp.config.in" "${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.config" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.config" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") + +# policy.0.0.ayatana-appindicator-sharp.dll + +find_program(AL al) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.dll" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator-sharp.dll" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${AL} + -link:"${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.config" + -out:"${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.dll" + -keyfile:"${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp.snk" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.dll" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") +install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${GACUTIL} -i ${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.dll -package ayatana-appindicator-sharp -root ${CMAKE_INSTALL_FULL_LIBDIR})") + +# policy.0.1.ayatana-appindicator-sharp.config + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/policy.0.1.ayatana-appindicator-sharp.config.in" "${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.config" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.config" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") + +# policy.0.1.ayatana-appindicator-sharp.dll + +find_program(AL al) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.dll" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/policy.0.0.ayatana-appindicator-sharp.dll" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${AL} + -link:"${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.config" + -out:"${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.dll" + -keyfile:"${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-sharp.snk" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/policy.0.1.ayatana-appindicator-sharp.dll" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cli/ayatana-appindicator-sharp3-0.1") + +add_custom_target("bindings-mono" ALL DEPENDS "policy.0.1.ayatana-appindicator-sharp.dll") + +if (ENABLE_TESTS) + add_subdirectory(examples) +endif() diff --git a/bindings/mono/examples/CMakeLists.txt b/bindings/mono/examples/CMakeLists.txt new file mode 100644 index 0000000..431a654 --- /dev/null +++ b/bindings/mono/examples/CMakeLists.txt @@ -0,0 +1,20 @@ +# ayatana-indicator-example + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ayatana-indicator-example.in" "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-example" @ONLY) + +# AyatanaIndicatorExample.exe + +find_program(MONO mono) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaIndicatorExample.exe" + DEPENDS "bindings-mono" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${MCS} + -out:"${CMAKE_CURRENT_BINARY_DIR}/AyatanaIndicatorExample.exe" + -target:exe + ${GTK_SHARP_3_0_LDFLAGS} "-r:${CMAKE_BINARY_DIR}/bindings/mono/ayatana-appindicator-sharp.dll" "${CMAKE_CURRENT_SOURCE_DIR}/AyatanaIndicatorExample.cs" +) + +add_custom_target("bindings-mono-examples" ALL DEPENDS "AyatanaIndicatorExample.exe") diff --git a/bindings/vala/CMakeLists.txt b/bindings/vala/CMakeLists.txt new file mode 100644 index 0000000..6d0aa5d --- /dev/null +++ b/bindings/vala/CMakeLists.txt @@ -0,0 +1,29 @@ +# ayatana-appindicator3-0.1.deps + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator3-0.1.deps" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/vala/vapi") + +# AyatanaAppIndicator3-0.1.vala + +find_package(Vala REQUIRED QUIET) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.vala" + DEPENDS "src" "${CMAKE_BINARY_DIR}/src/AyatanaAppIndicator3-0.1.typelib" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${VAPI_GEN} + --library=ayatana-appindicator3-0.1 + --pkg gtk+-3.0 + --girdir="${CMAKE_SOURCE_DIR}/src" + --metadatadir "${CMAKE_SOURCE_DIR}/src" + "${CMAKE_BINARY_DIR}/src/AyatanaAppIndicator3-0.1.gir" + "${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator-0.1-custom.vala" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator3-0.1.vapi" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/vala/vapi") + +add_custom_target("bindings-vala" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.vala") + +if (ENABLE_TESTS) + add_subdirectory(examples) +endif() diff --git a/bindings/vala/examples/CMakeLists.txt b/bindings/vala/examples/CMakeLists.txt new file mode 100644 index 0000000..f393939 --- /dev/null +++ b/bindings/vala/examples/CMakeLists.txt @@ -0,0 +1,27 @@ +# ayatana-indicator-example.c + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-example.c" + DEPENDS "bindings-vala" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${VALA_COMPILER} + --pkg ayatana-appindicator3-0.1 + --pkg gtk+-3.0 + --vapidir=${CMAKE_BINARY_DIR}/bindings/vala + -C ayatana-indicator-example.vala + --metadatadir "${CMAKE_SOURCE_DIR}/src" + --directory=${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + COMMAND + sed + -i "s|#include\\s*<\\s*libayatana-appindicator/app-indicator.h\\s*>||g" + "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-example.c" +) + +# ayatana-indicator-example + +set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-example.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -include ${CMAKE_SOURCE_DIR}/src/app-indicator.h") +add_executable("ayatana-indicator-example" "${CMAKE_CURRENT_BINARY_DIR}/ayatana-indicator-example.c") +target_include_directories("ayatana-indicator-example" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_link_libraries("ayatana-indicator-example" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3 -L${CMAKE_BINARY_DIR}/src") diff --git a/cmake/FindGObjectIntrospection.cmake b/cmake/FindGObjectIntrospection.cmake new file mode 100644 index 0000000..2073c3c --- /dev/null +++ b/cmake/FindGObjectIntrospection.cmake @@ -0,0 +1,61 @@ +# - try to find gobject-introspection +# +# Once done this will define +# +# INTROSPECTION_FOUND - system has gobject-introspection +# INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner +# INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler +# INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate +# INTROSPECTION_GIRDIR +# INTROSPECTION_TYPELIBDIR +# INTROSPECTION_CFLAGS +# INTROSPECTION_LIBS +# +# Copyright (C) 2010, Pino Toscano, <pino@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0 + OUTPUT_VARIABLE _result + RESULT_VARIABLE _null + ) + + if (_null) + else() + string(REGEX REPLACE "[\r\n]" " " _result "${_result}") + string(REGEX REPLACE " +$" "" _result "${_result}") + separate_arguments(_result) + set(${_outvar} ${_result} CACHE INTERNAL "") + endif() +endmacro(_GIR_GET_PKGCONFIG_VAR) + +find_package(PkgConfig) +if(PKG_CONFIG_FOUND) + if(PACKAGE_FIND_VERSION_COUNT GREATER 0) + set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}") + endif() + pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp}) + if(_pc_gir_FOUND) + set(INTROSPECTION_FOUND TRUE) + _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner") + _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler") + _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate") + _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir") + _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir") + set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}") + set(INTROSPECTION_LIBS "${_pc_gir_LIBS}") + endif() +endif() + +mark_as_advanced( + INTROSPECTION_SCANNER + INTROSPECTION_COMPILER + INTROSPECTION_GENERATE + INTROSPECTION_GIRDIR + INTROSPECTION_TYPELIBDIR + INTROSPECTION_CFLAGS + INTROSPECTION_LIBS +) diff --git a/cmake/FindVala.cmake b/cmake/FindVala.cmake new file mode 100644 index 0000000..a638735 --- /dev/null +++ b/cmake/FindVala.cmake @@ -0,0 +1,57 @@ +# - Find Vala +# This module looks for valac. +# This module defines the following values: +# VALA_FOUND +# VALA_COMPILER +# VALA_VERSION +# VAPI_GEN +# VAPI_GEN_VERSION + +#============================================================================= +# Copyright Přemysl Janouch 2011 +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +# OF SUCH DAMAGE. +#============================================================================= + +find_program (VALA_COMPILER "valac") + +if (VALA_COMPILER) + execute_process (COMMAND ${VALA_COMPILER} --version + OUTPUT_VARIABLE VALA_VERSION) + string (REGEX MATCH "[.0-9]+" VALA_VERSION "${VALA_VERSION}") +endif (VALA_COMPILER) + +find_program (VAPI_GEN "vapigen") + +if (VAPI_GEN) + execute_process (COMMAND ${VAPI_GEN} --version + OUTPUT_VARIABLE VAPI_GEN_VERSION) + string (REGEX MATCH "[.0-9]+" VAPI_GEN_VERSION "${VAPI_GEN_VERSION}") +endif (VAPI_GEN) + +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS (Vala + REQUIRED_VARS VALA_COMPILER + VERSION_VAR VALA_VERSION) + +mark_as_advanced (VALA_COMPILER VALA_VERSION VAPI_GEN) + diff --git a/cmake/UseGObjectIntrospection.cmake b/cmake/UseGObjectIntrospection.cmake new file mode 100644 index 0000000..d6d1810 --- /dev/null +++ b/cmake/UseGObjectIntrospection.cmake @@ -0,0 +1,100 @@ +# Copyright (C) 2010, Pino Toscano, <pino@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(ListOperations) + +macro(_gir_list_prefix _outvar _listvar _prefix) + set(${_outvar}) + foreach(_item IN LISTS ${_listvar}) + list(APPEND ${_outvar} ${_prefix}${_item}) + endforeach() +endmacro(_gir_list_prefix) + +macro(gir_add_introspections introspections_girs) + + foreach(gir IN LISTS ${introspections_girs}) + + set(_gir_name "${gir}") + + ## Transform the gir filename to something which can reference through a variable + ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir + string(REPLACE "-" "_" _gir_name "${_gir_name}") + string(REPLACE "." "_" _gir_name "${_gir_name}") + + # Namespace and Version is either fetched from the gir filename + # or the _NAMESPACE/_VERSION variable combo + set(_gir_namespace "${${_gir_name}_NAMESPACE}") + if (_gir_namespace STREQUAL "") + string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}") + endif () + set(_gir_version "${${_gir_name}_VERSION}") + if (_gir_version STREQUAL "") + string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}") + endif () + + # _PROGRAM is an optional variable which needs it's own --program argument + set(_gir_program "${${_gir_name}_PROGRAM}") + if (NOT _gir_program STREQUAL "") + set(_gir_program "--program=${_gir_program}") + endif () + + # Variables which provides a list of things + _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=") + _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=") + _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=") + _gir_list_prefix(_gir_export_packages ${_gir_name}_EXPORT_PACKAGES "--pkg-export=") + + # Reuse the LIBTOOL variable from by automake if it's set + set(_gir_libtool "--no-libtool") + + add_custom_command( + COMMAND ${INTROSPECTION_SCANNER} + ${INTROSPECTION_SCANNER_ARGS} + --namespace=${_gir_namespace} + --nsversion=${_gir_version} + ${_gir_libtool} + ${_gir_program} + ${_gir_libraries} + ${_gir_packages} + ${_gir_includes} + ${_gir_export_packages} + ${${_gir_name}_SCANNERFLAGS} + ${${_gir_name}_CFLAGS} + ${${_gir_name}_FILES} + --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} + DEPENDS ${${_gir_name}_FILES} + ${${_gir_name}_LIBS} + OUTPUT ${gir} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0) + + string(REPLACE ".gir" ".typelib" _typelib "${gir}") + add_custom_command( + COMMAND ${INTROSPECTION_COMPILER} + ${INTROSPECTION_COMPILER_ARGS} + --includedir=. + ${CMAKE_CURRENT_BINARY_DIR}/${gir} + -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir} + OUTPUT ${_typelib} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0) + + add_custom_target(gir-${gir} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}) + add_custom_target(gir-typelibs-${_typelib} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}) + endforeach() + +endmacro(gir_add_introspections) + +macro(gir_get_cflags _output) + get_directory_property(_tmp_includes INCLUDE_DIRECTORIES) + list_prefix(_includes _tmp_includes "-I") + get_directory_property(_tmp_compile_definitions COMPILE_DEFINITIONS) + list_prefix(_compile_definitions _tmp_compile_definitions "-D") + set(${_output} ${_includes} ${_compile_definitions}) +endmacro(gir_get_cflags) diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake new file mode 100644 index 0000000..f0202e2 --- /dev/null +++ b/cmake/UseVala.cmake @@ -0,0 +1,241 @@ +# - Precompilation of Vala/Genie source files into C sources +# Makes use of the parallel build ability introduced in Vala 0.11. Derived +# from a similar module by Jakob Westhoff and the original GNU Make rules. +# Might be a bit oversimplified. +# +# This module defines three functions. The first one: +# +# vala_init (id +# [DIRECTORY dir] - Output directory (binary dir by default) +# [PACKAGES package...] - Package dependencies +# [OPTIONS option...] - Extra valac options +# [CUSTOM_VAPIS file...]) - Custom vapi files to include in the build +# [DEPENDS targets...]) - Extra dependencies for code generation +# +# initializes a single precompilation unit using the given arguments. +# You can put files into it via the following function: +# +# vala_add (id source.vala +# [DEPENDS source...]) - Vala/Genie source or .vapi dependencies +# +# Finally retrieve paths for generated C files by calling: +# +# vala_finish (id +# [SOURCES sources_var] - Input Vala/Genie sources +# [OUTPUTS outputs_var] - Output C sources +# [GENERATE_HEADER id.h - Generate id.h and id_internal.h +# [GENERATE_VAPI id.vapi] - Generate a vapi file +# [GENERATE_SYMBOLS id.def]]) - Generate a list of public symbols +# + +#============================================================================= +# Copyright Přemysl Janouch 2011 +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +# OF SUCH DAMAGE. +#============================================================================= + +find_package (Vala 0.20 REQUIRED) +include (CMakeParseArguments) + +function (vala_init id) + set (_multi_value PACKAGES OPTIONS CUSTOM_VAPIS DEPENDS) + cmake_parse_arguments (arg "" "DIRECTORY" "${_multi_value}" ${ARGN}) + + if (arg_DIRECTORY) + set (directory ${arg_DIRECTORY}) + if (NOT IS_DIRECTORY ${directory}) + file (MAKE_DIRECTORY ${directory}) + endif (NOT IS_DIRECTORY ${directory}) + else (arg_DIRECTORY) + set (directory ${CMAKE_CURRENT_BINARY_DIR}) + endif (arg_DIRECTORY) + + set (pkg_opts) + foreach (pkg ${arg_PACKAGES}) + list (APPEND pkg_opts "--pkg=${pkg}") + endforeach (pkg) + + set (VALA_${id}_DIR "${directory}" PARENT_SCOPE) + set (VALA_${id}_ARGS ${pkg_opts} ${arg_OPTIONS} + ${arg_CUSTOM_VAPIS} PARENT_SCOPE) + set (VALA_${id}_DEPENDS ${arg_DEPENDS} + PARENT_SCOPE) + + set (VALA_${id}_SOURCES "" PARENT_SCOPE) + set (VALA_${id}_OUTPUTS "" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_FILES "" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_ARGS "" PARENT_SCOPE) +endfunction (vala_init) + +function (vala_add id file) + cmake_parse_arguments (arg "" "" "DEPENDS" ${ARGN}) + + if (NOT IS_ABSOLUTE "${file}") + set (file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + endif (NOT IS_ABSOLUTE "${file}") + + get_filename_component (output_name "${file}" NAME) + get_filename_component (output_base "${file}" NAME_WE) + set (output_base "${VALA_${id}_DIR}/${output_base}") + + # XXX: It would be best to have it working without touching the vapi + # but it appears this cannot be done in CMake. + add_custom_command (OUTPUT "${output_base}.vapi" + COMMAND ${VALA_COMPILER} "${file}" "--fast-vapi=${output_base}.vapi" + COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.vapi" + DEPENDS "${file}" + COMMENT "Generating a fast vapi for ${output_name}" VERBATIM) + + set (vapi_opts) + set (vapi_depends) + foreach (vapi ${arg_DEPENDS}) + if (NOT IS_ABSOLUTE "${vapi}") + set (vapi "${VALA_${id}_DIR}/${vapi}.vapi") + endif (NOT IS_ABSOLUTE "${vapi}") + + list (APPEND vapi_opts "--use-fast-vapi=${vapi}") + list (APPEND vapi_depends "${vapi}") + endforeach (vapi) + + add_custom_command (OUTPUT "${output_base}.c" + COMMAND ${VALA_COMPILER} "${file}" -C ${vapi_opts} ${VALA_${id}_ARGS} + COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.c" + DEPENDS "${file}" ${vapi_depends} ${VALA_${id}_DEPENDS} + WORKING_DIRECTORY "${VALA_${id}_DIR}" + COMMENT "Precompiling ${output_name}" VERBATIM) + + set (VALA_${id}_SOURCES ${VALA_${id}_SOURCES} + "${file}" PARENT_SCOPE) + set (VALA_${id}_OUTPUTS ${VALA_${id}_OUTPUTS} + "${output_base}.c" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_FILES ${VALA_${id}_FAST_VAPI_FILES} + "${output_base}.vapi" PARENT_SCOPE) + set (VALA_${id}_FAST_VAPI_ARGS ${VALA_${id}_FAST_VAPI_ARGS} + "--use-fast-vapi=${output_base}.vapi" PARENT_SCOPE) +endfunction (vala_add) + +function (vala_finish id) + set (_one_value SOURCES OUTPUTS + GENERATE_VAPI GENERATE_HEADER GENERATE_SYMBOLS) + cmake_parse_arguments (arg "" "${_one_value}" "" ${ARGN}) + + if (arg_SOURCES) + set (${arg_SOURCES} ${VALA_${id}_SOURCES} PARENT_SCOPE) + endif (arg_SOURCES) + + if (arg_OUTPUTS) + set (${arg_OUTPUTS} ${VALA_${id}_OUTPUTS} PARENT_SCOPE) + endif (arg_OUTPUTS) + + set (outputs) + set (export_args) + + if (arg_GENERATE_VAPI) + if (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") + set (arg_GENERATE_VAPI + "${VALA_${id}_DIR}/${arg_GENERATE_VAPI}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") + + list (APPEND outputs "${arg_GENERATE_VAPI}") + list (APPEND export_args "--internal-vapi=${arg_GENERATE_VAPI}") + + if (NOT arg_GENERATE_HEADER) + message (FATAL_ERROR "Header generation required for vapi") + endif (NOT arg_GENERATE_HEADER) + endif (arg_GENERATE_VAPI) + + if (arg_GENERATE_SYMBOLS) + if (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") + set (arg_GENERATE_SYMBOLS + "${VALA_${id}_DIR}/${arg_GENERATE_SYMBOLS}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") + + list (APPEND outputs "${arg_GENERATE_SYMBOLS}") + list (APPEND export_args "--symbols=${arg_GENERATE_SYMBOLS}") + + if (NOT arg_GENERATE_HEADER) + message (FATAL_ERROR "Header generation required for symbols") + endif (NOT arg_GENERATE_HEADER) + endif (arg_GENERATE_SYMBOLS) + + if (arg_GENERATE_HEADER) + if (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") + set (arg_GENERATE_HEADER + "${VALA_${id}_DIR}/${arg_GENERATE_HEADER}") + endif (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") + + get_filename_component (header_path "${arg_GENERATE_HEADER}" PATH) + get_filename_component (header_name "${arg_GENERATE_HEADER}" NAME_WE) + set (header_base "${header_path}/${header_name}") + get_filename_component (header_ext "${arg_GENERATE_HEADER}" EXT) + + list (APPEND outputs + "${header_base}${header_ext}" + "${header_base}_internal${header_ext}") + list (APPEND export_args + "--header=${header_base}${header_ext}" + "--internal-header=${header_base}_internal${header_ext}") + endif (arg_GENERATE_HEADER) + + if (outputs) + add_custom_command (OUTPUT ${outputs} + COMMAND ${VALA_COMPILER} -C ${VALA_${id}_ARGS} + ${export_args} ${VALA_${id}_FAST_VAPI_ARGS} + DEPENDS ${VALA_${id}_FAST_VAPI_FILES} + COMMENT "Generating vapi/headers/symbols" VERBATIM) + endif (outputs) +endfunction (vala_finish id) + + +function (vapi_gen id) + set (_one_value LIBRARY INPUT) + set (_multi_value PACKAGES) + cmake_parse_arguments (arg "" "${_one_value}" "${_multi_value}" ${ARGN}) + + set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${id}.vapi") + if (arg_LIBRARY) + set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_LIBRARY}.vapi") + endif (arg_LIBRARY) + + set("${id}_OUTPUT" ${OUTPUT} PARENT_SCOPE) + + set(PACKAGE_LIST) + foreach(PACKAGE ${arg_PACKAGES}) + list(APPEND PACKAGE_LIST "--pkg" ${PACKAGE}) + endforeach() + + add_custom_command( + OUTPUT + ${OUTPUT} + COMMAND + ${VAPI_GEN} + ${PACKAGE_LIST} + --library=${arg_LIBRARY} + ${arg_INPUT} + DEPENDS + ${arg_INPUT} + VERBATIM + ) + + add_custom_target(${id} ALL DEPENDS ${OUTPUT}) +endfunction (vapi_gen id) + diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 0000000..90bb2b5 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(reference) diff --git a/docs/reference/CMakeLists.txt b/docs/reference/CMakeLists.txt new file mode 100644 index 0000000..6ae064a --- /dev/null +++ b/docs/reference/CMakeLists.txt @@ -0,0 +1,233 @@ + +# libayatana-appindicator-docs.sgml + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libayatana-appindicator-docs.sgml.in" "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-docs.sgml" @ONLY) + +# version.xml + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/version.xml" @ONLY) + +# libayatana-appindicator-decl.txt +# libayatana-appindicator-decl-list.txt +# libayatana-appindicator-overrides.txt +# libayatana-appindicator-sections.txt + +find_program(GTKDOC_SCAN gtkdoc-scan) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-decl.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-decl-list.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-overrides.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-sections.txt" + DEPENDS "src" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${GTKDOC_SCAN} + --ignore-headers="app-indicator-enum-types.h;application-service-appstore.h;application-service-client.h;application-service-lru-file.h;application-service-marshal.h;application-service-server.h;application-service-watcher.h;dbus-properties-client.h;dbus-properties-server.h;dbus-shared.h;generate-id.h;notification-item-client.h;notification-item-server.h;notification-watcher-client.h;notification-watcher-server.h" + --module=libayatana-appindicator + --source-dir="${CMAKE_SOURCE_DIR}/src" + --source-dir="${CMAKE_BINARY_DIR}/src" +) + +# libayatana-appindicator.types + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.types" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-decl.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-decl-list.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-overrides.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-sections.txt" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${CMAKE_COMMAND} + -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/libayatana-appindicator.types" + "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.types" +) + +# scangobj.sh + +list(JOIN PROJECT_DEPS_INCLUDE_DIRS " -I" GTKDOC_SCANGOBJ_INCLUDE_DIRS) +list(JOIN PROJECT_DEPS_LIBRARIES " -l" GTKDOC_SCANGOBJ_LIBRARIES) + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scangobj.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/scangobj.sh") + +# libayatana-appindicator.actions +# libayatana-appindicator.args +# libayatana-appindicator.hierarchy +# libayatana-appindicator.interfaces +# libayatana-appindicator.prerequisites +# libayatana-appindicator.signals + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.actions" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.args" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.hierarchy" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.interfaces" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.prerequisites" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.signals" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.types" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND sh scangobj.sh +) + +# gtkdocentities.ent + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "<!ENTITY package \"libayatana-appindicator\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_bugreport \"https://github.com/AyatanaIndicators/libayatana-appindicator/issues\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_name \"libayatana-appindicator\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_string \"libayatana-appindicator ${PROJECT_VERSION}\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_tarname \"libayatana-appindicator\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_url \"https://github.com/AyatanaIndicators/libayatana-appindicator\">") +file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/xml/gtkdocentities.ent" "\n<!ENTITY package_version \"${PROJECT_VERSION}\">") + +# libayatana-appindicator-undeclared.txt +# libayatana-appindicator-undocumented.txt +# libayatana-appindicator-unused.txt +# xml/annotation-glossary.xml +# xml/api-index-0.5.xml +# xml/api-index-deprecated.xml +# xml/api-index-full.xml +# xml/app-indicator.xml +# xml/libayatana-appindicator-doc.bottom +# xml/libayatana-appindicator-doc.top +# xml/object_index.sgml +# xml/tree_index.sgml + +find_program(GTKDOC_MKDB gtkdoc-mkdb) +list(JOIN PROJECT_DEPS_INCLUDE_DIRS ";-I" GTKDOC_SCANGOBJ_INCLUDE_DIRS) +list(JOIN PROJECT_DEPS_LIBRARIES ";-l" GTKDOC_SCANGOBJ_LIBRARIES) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-undeclared.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-undocumented.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-unused.txt" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/annotation-glossary.xml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-0.5.xml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-deprecated.xml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-full.xml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/app-indicator.xml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/libayatana-appindicator-doc.bottom" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/libayatana-appindicator-doc.top" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/object_index.sgml" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml/tree_index.sgml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.actions" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.args" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.hierarchy" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.interfaces" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.prerequisites" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator.signals" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${GTKDOC_MKDB} + --module=libayatana-appindicator + --output-format=xml + --expand-content-files="" + --main-sgml-file=libayatana-appindicator-docs.sgml + --source-dir="${CMAKE_SOURCE_DIR}/src" + --sgml-mode +) + +# html +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html") + +# html/annotation-glossary.html +# html/api-index-0-5.html +# html/api-index-deprecated.html +# html/api-index-full.html +# html/AppIndicator.html +# html/ch01.html +# html/home.png +# html/index.html +# html/left.png +# html/left-insensitive.png +# html/libayatana-appindicator.devhelp2 +# html/object-tree.html +# html/right.png +# html/right-insensitive.png +# html/style.css +# html/up.png +# html/up-insensitive.png + +find_program(GTKDOC_MKHTML gtkdoc-mkhtml) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/annotation-glossary.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-0-5.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-deprecated.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-full.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/AppIndicator.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/ch01.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/home.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/index.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/left.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/left-insensitive.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/libayatana-appindicator.devhelp2" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/object-tree.html" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/right.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/right-insensitive.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/style.css" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/up.png" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/up-insensitive.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-undeclared.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-undocumented.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator-unused.txt" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/annotation-glossary.xml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-0.5.xml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-deprecated.xml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/api-index-full.xml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/app-indicator.xml" "xml/libayatana-appindicator-doc.bottom" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/libayatana-appindicator-doc.top" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/object_index.sgml" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xml/tree_index.sgml" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" + COMMAND + ${GTKDOC_MKHTML} + --path=${CMAKE_CURRENT_BINARY_DIR} + libayatana-appindicator + libayatana-appindicator-docs.sgml +) + +# html/annotation-glossary.html +# html/api-index-0-5.html +# html/api-index-deprecated.html +# html/api-index-full.html +# html/AppIndicator.html +# html/ch01.html +# html/index.html +# html/object-tree.html +# html/style.css + +find_program(GTKDOC_FIXXREF gtkdoc-fixxref) + +add_custom_command( + OUTPUT "fixxref" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/annotation-glossary.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-0-5.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-deprecated.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/api-index-full.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/AppIndicator.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/ch01.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/home.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/index.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/left.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/left-insensitive.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/libayatana-appindicator.devhelp2" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/object-tree.html" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/right.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/right-insensitive.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/style.css" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/up.png" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/up-insensitive.png" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${GTKDOC_FIXXREF} + --module=libayatana-appindicator + --module-dir=html + --html-dir="${CMAKE_INSTALL_FULL_DATADIR}/gtk-doc/html" +) + +set_source_files_properties("fixxref" PROPERTIES SYMBOLIC True) +install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/gtk-doc/html/libayatana-appindicator") + +add_custom_target("docs-references" ALL DEPENDS "fixxref") diff --git a/docs/reference/scangobj.sh.in b/docs/reference/scangobj.sh.in new file mode 100644 index 0000000..0272865 --- /dev/null +++ b/docs/reference/scangobj.sh.in @@ -0,0 +1 @@ +LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${CMAKE_BINARY_DIR}/src" CFLAGS="-I${GTKDOC_SCANGOBJ_INCLUDE_DIRS}" LDFLAGS="-l${GTKDOC_SCANGOBJ_LIBRARIES} -L${CMAKE_BINARY_DIR}/src -layatana-appindicator3" gtkdoc-scangobj --type-init-func="g_type_init()" --module=libayatana-appindicator > /dev/null diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..ba8839e --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,37 @@ +# simple-client-vala.c + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/simple-client-vala.c" + DEPENDS "bindings-vala" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${VALA_COMPILER} + --pkg ayatana-appindicator3-0.1 + --pkg gtk+-3.0 + --vapidir=${CMAKE_BINARY_DIR}/bindings/vala + -C simple-client-vala.vala + --directory=${CMAKE_CURRENT_BINARY_DIR} + VERBATIM + COMMAND + sed + -i "s|#include\\s*<\\s*libayatana-appindicator/app-indicator.h\\s*>||g" + "${CMAKE_CURRENT_BINARY_DIR}/simple-client-vala.c" +) + +# simple-client-vala + +set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/simple-client-vala.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -include ${CMAKE_SOURCE_DIR}/src/app-indicator.h") +add_executable("simple-client-vala" "${CMAKE_CURRENT_BINARY_DIR}/simple-client-vala.c") +target_include_directories("simple-client-vala" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_link_libraries("simple-client-vala" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3 -L${CMAKE_BINARY_DIR}/src") +add_dependencies("simple-client-vala" "ayatana-appindicator3") + +# simple-client + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/simple-client.c" PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_executable("simple-client" "${CMAKE_CURRENT_SOURCE_DIR}/simple-client.c") +target_compile_definitions("simple-client" PUBLIC LOCAL_ICON="${CMAKE_CURRENT_SOURCE_DIR}/simple-client-test-icon.png") +target_include_directories("simple-client" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("simple-client" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("simple-client" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3 -L${CMAKE_BINARY_DIR}/src") +add_dependencies("simple-client" "ayatana-appindicator3") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..3a0ce71 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,166 @@ +set(HEADERS + app-indicator.h +) + +set(SOURCES + app-indicator.c + app-indicator-enum-types.c + application-service-marshal.c + generate-id.c + gen-notification-item.xml.c + gen-notification-watcher.xml.c +) + +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/app-indicator.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-appindicator3-0.1/libayatana-appindicator") + +# ayatana-appindicator3-0.1.pc + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ayatana-appindicator3-0.1.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator3-0.1.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ayatana-appindicator3-0.1.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + +# app-indicator-enum-types.h + +find_program(GLIB_MKENUMS glib-mkenums) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.h" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_MKENUMS} + --template app-indicator-enum-types.h.in + ${HEADERS} + --output="${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.h" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libayatana-appindicator3-0.1/libayatana-appindicator") + +# app-indicator-enum-types.c + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.c" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.h" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_MKENUMS} + --template app-indicator-enum-types.c.in + ${HEADERS} + --output="${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.c" +) + +find_program(GLIB_GENMARSHAL glib-genmarshal) + +# application-service-marshal.h + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/application-service-marshal.h" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-enum-types.c" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_GENMARSHAL} + --prefix=_application_service_marshal + --header application-service-marshal.list + --quiet + --output="${CMAKE_CURRENT_BINARY_DIR}/application-service-marshal.h" +) + +# application-service-marshal.c + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/application-service-marshal.c" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/application-service-marshal.h" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${GLIB_GENMARSHAL} + --prefix=_application_service_marshal + --body application-service-marshal.list + --include-header=application-service-marshal.h + --quiet + --output="${CMAKE_CURRENT_BINARY_DIR}/application-service-marshal.c" +) + +# gen-notification-item.xml.h + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-notification-item.xml.h" "extern const char * _notification_item;") + +# gen-notification-item.xml.c + +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/notification-item.xml" GEN_NOTIFICATION_ITEM_XML_C) +string(REPLACE "\"" "\\\"" GEN_NOTIFICATION_ITEM_XML_C ${GEN_NOTIFICATION_ITEM_XML_C}) +string(REPLACE "\n" "\\n\"\n\"" GEN_NOTIFICATION_ITEM_XML_C ${GEN_NOTIFICATION_ITEM_XML_C}) +string(REGEX REPLACE "\n\"$" "\n" GEN_NOTIFICATION_ITEM_XML_C ${GEN_NOTIFICATION_ITEM_XML_C}) +string(PREPEND GEN_NOTIFICATION_ITEM_XML_C "const char * _notification_item = \n\"") +string(APPEND GEN_NOTIFICATION_ITEM_XML_C "\;") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-notification-item.xml.c" ${GEN_NOTIFICATION_ITEM_XML_C}) + +# gen-notification-watcher.xml.h + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-notification-watcher.xml.h" "extern const char * _notification_watcher;") + +# gen-notification-watcher.xml.c + +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/notification-watcher.xml" GEN_NOTIFICATION_WATCHER_XML_C) +string(REPLACE "\"" "\\\"" GEN_NOTIFICATION_WATCHER_XML_C ${GEN_NOTIFICATION_WATCHER_XML_C}) +string(REPLACE "\n" "\\n\"\n\"" GEN_NOTIFICATION_WATCHER_XML_C ${GEN_NOTIFICATION_WATCHER_XML_C}) +string(REGEX REPLACE "\n\"$" "\n" GEN_NOTIFICATION_WATCHER_XML_C ${GEN_NOTIFICATION_WATCHER_XML_C}) +string(PREPEND GEN_NOTIFICATION_WATCHER_XML_C "const char * _notification_watcher = \n\"") +string(APPEND GEN_NOTIFICATION_WATCHER_XML_C "\;") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/gen-notification-watcher.xml.c" ${GEN_NOTIFICATION_WATCHER_XML_C}) + +# libayatana-appindicator3.so + +set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_library("ayatana-appindicator3" SHARED ${SOURCES}) +set_target_properties("ayatana-appindicator3" PROPERTIES VERSION 1.0.0 SOVERSION 1) +target_compile_definitions("ayatana-appindicator3" PUBLIC G_LOG_DOMAIN="libayatana-appindicator") +target_include_directories("ayatana-appindicator3" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("ayatana-appindicator3" PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories("ayatana-appindicator3" PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries("ayatana-appindicator3" ${PROJECT_DEPS_LIBRARIES}) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator3.so" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator3.so.1" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libayatana-appindicator3.so.1.0.0" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}") + +# AyatanaAppIndicator3-0.1.gir + +find_package(GObjectIntrospection REQUIRED QUIET) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.gir" + DEPENDS "ayatana-appindicator3" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND + ${INTROSPECTION_SCANNER} + app-indicator.c ${HEADERS} + --add-include-path=${CMAKE_CURRENT_BINARY_DIR} + --c-include=libayatana-appindicator/app-indicator.h + --symbol-prefix=app + --identifier-prefix=App + --namespace=AyatanaAppIndicator3 + --nsversion=0.1 + --quiet + --warn-all + --include=GObject-2.0 + --include=Gtk-3.0 + --library-path=${CMAKE_CURRENT_BINARY_DIR} + --library="ayatana-appindicator3" + --output "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.gir" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.gir" DESTINATION "${CMAKE_INSTALL_FULL_DATADIR}/gir-1.0") + +# AyatanaAppIndicator3-0.1.typelib + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.typelib" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.gir" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND + ${INTROSPECTION_COMPILER} + --includedir=${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.gir + -o "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.typelib" +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.typelib" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/girepository-1.0") + +add_custom_target(src ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/AyatanaAppIndicator3-0.1.typelib") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..03771ba --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,184 @@ +# test-libappindicator + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -include ${CMAKE_SOURCE_DIR}/src/app-indicator.h") +add_executable("test-libappindicator" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator.c") +target_compile_definitions("test-libappindicator" PUBLIC SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") +target_include_directories("test-libappindicator" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-libappindicator" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-libappindicator" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator" "ayatana-appindicator3") + +# test-libappindicator-dbus-client + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-dbus-client" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-dbus-client.c") +target_include_directories("test-libappindicator-dbus-client" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-libappindicator-dbus-client" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-libappindicator-dbus-client" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-dbus-client" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-dbus-client" "ayatana-appindicator3") + +# test-libappindicator-dbus-server + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-dbus-server.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-dbus-server" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-dbus-server.c") +target_include_directories("test-libappindicator-dbus-server" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-libappindicator-dbus-server" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-libappindicator-dbus-server" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-dbus-server" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-dbus-server" "ayatana-appindicator3") + +# test-libappindicator-status-client + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-status-client.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-status-client" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-status-client.c") +target_include_directories("test-libappindicator-status-client" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_link_libraries("test-libappindicator-status-client" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-status-client" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-status-client" "ayatana-appindicator3") + +# test-libappindicator-status-server + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-status-server.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-status-server" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-status-server.c") +target_include_directories("test-libappindicator-status-server" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-libappindicator-status-server" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-libappindicator-status-server" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-status-server" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-status-server" "ayatana-appindicator3") + +# test-libappindicator-fallback-item + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-fallback-item.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-fallback-item" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-fallback-item.c") +target_include_directories("test-libappindicator-fallback-item" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-libappindicator-fallback-item" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-libappindicator-fallback-item" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-fallback-item" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-fallback-item" "ayatana-appindicator3") + +# test-libappindicator-fallback-watcher + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-fallback-watcher.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-libappindicator-fallback-watcher" "${CMAKE_CURRENT_SOURCE_DIR}/test-libappindicator-fallback-watcher.c") +target_include_directories("test-libappindicator-fallback-watcher" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_link_libraries("test-libappindicator-fallback-watcher" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-libappindicator-fallback-watcher" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-libappindicator-fallback-watcher" "ayatana-appindicator3") + +# test-simple-app + +set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/test-simple-app.c" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") +add_executable("test-simple-app" "${CMAKE_CURRENT_SOURCE_DIR}/test-simple-app.c") +target_include_directories("test-simple-app" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_include_directories("test-simple-app" PUBLIC "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-simple-app" "${PROJECT_DEPS_LIBRARIES} -layatana-appindicator3") +target_link_directories("test-simple-app" PUBLIC "${CMAKE_BINARY_DIR}/src") +add_dependencies("test-simple-app" "ayatana-appindicator3") + +# test-libappindicator-fallback + +find_program(DBUS_TEST_RUNNER dbus-test-runner) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback-watcher" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback-item" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + COMMAND + echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" + COMMAND + echo "export DISPLAY=" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" + COMMAND + echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" + COMMAND + echo "${DBUS_TEST_RUNNER} -m 300 --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback-watcher --task-name Watcher --ignore-return --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback-item --task-name Item" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" + COMMAND + chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-fallback" +) + +add_test("test-libappindicator-fallback" "test-libappindicator-fallback") + +# test-libappindicator-dbus + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus-client" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus-server" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + COMMAND + echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" + COMMAND + echo "export DISPLAY=" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" + COMMAND + echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" + COMMAND + echo "${DBUS_TEST_RUNNER} -m 300 --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus-client --task-name Client --ignore-return --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus-server --task-name Server" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" + COMMAND + chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-dbus" +) + +add_test("test-libappindicator-dbus" "test-libappindicator-dbus") + +# test-libappindicator-status + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status-client" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status-server" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + COMMAND + echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" + COMMAND + echo "export DISPLAY=" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" + COMMAND + echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" + COMMAND + echo "${DBUS_TEST_RUNNER} -m 300 --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status-client --task-name Client --ignore-return --task ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status-server --task-name Server" >> "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" + COMMAND + chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator-status" +) + +add_test("test-libappindicator-status" "test-libappindicator-status") + +# libappindicator-tests-gtester + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + COMMAND + echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" + COMMAND + echo "gtester -k --verbose -o=${CMAKE_CURRENT_BINARY_DIR}/libappindicator-check-results.xml ${CMAKE_CURRENT_BINARY_DIR}/test-libappindicator" >> "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" + COMMAND + chmod +x "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" +) + +# libappindicator-tests + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + COMMAND + echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" + COMMAND + echo "export DISPLAY=" >> "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" + COMMAND + echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" + COMMAND + echo "${DBUS_TEST_RUNNER} -m 300 --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests-gtester" >> "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" + COMMAND + chmod +x "${CMAKE_CURRENT_BINARY_DIR}/libappindicator-tests" +) + +add_test("libappindicator-tests" "libappindicator-tests") + +add_custom_target("tests" ALL DEPENDS "test-libappindicator-fallback" "test-libappindicator-dbus" "test-libappindicator-status" "libappindicator-tests") |