aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Berhoerster <guido+ayatana@berhoerster.name>2021-03-01 19:13:17 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2026-06-10 09:56:51 +0200
commit808727b9b49328d8e46097fccdd1614de774ed00 (patch)
tree596942f70f2a6a98680e7344afca0d351976c613
parent2ea7c4ae2e9c93d698f4d9065ebd5a49904720c6 (diff)
downloadlibayatana-appindicator-808727b9b49328d8e46097fccdd1614de774ed00.tar.gz
libayatana-appindicator-808727b9b49328d8e46097fccdd1614de774ed00.tar.bz2
libayatana-appindicator-808727b9b49328d8e46097fccdd1614de774ed00.zip
Add macros for compile-time version checking
-rw-r--r--CMakeLists.txt7
-rw-r--r--docs/reference/libayatana-appindicator-sections.txt12
-rw-r--r--src/CMakeLists.txt25
-rw-r--r--src/app-indicator-version.h.in109
-rw-r--r--src/app-indicator.h4
5 files changed, 153 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13d31e9..cd98b4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.13)
-project(libayatana-appindicator C)
+project(libayatana-appindicator
+ VERSION 0.5.90
+ LANGUAGES C
+)
set(PROJECT_VERSION "0.5.94")
set(PROJECT_NAME "libayatana-appindicator")
@@ -78,6 +81,8 @@ if (ENABLE_GTKDOC)
endif()
endif()
+add_compile_definitions(APP_INDICATOR_COMPILATION)
+
# Make everything
add_subdirectory(src)
diff --git a/docs/reference/libayatana-appindicator-sections.txt b/docs/reference/libayatana-appindicator-sections.txt
index ab86216..9664f38 100644
--- a/docs/reference/libayatana-appindicator-sections.txt
+++ b/docs/reference/libayatana-appindicator-sections.txt
@@ -49,3 +49,15 @@ app_indicator_get_secondary_activate_target
app_indicator_get_title
app_indicator_build_menu_from_desktop
</SECTION>
+
+<SECTION>
+<FILE>app-indicator-version</FILE>
+<TITLE>Versioning</TITLE>
+AYATANA_APP_INDICATOR_MAJOR_VERSION
+AYATANA_APP_INDICATOR_MINOR_VERSION
+AYATANA_APP_INDICATOR_MICRO_VERSION
+AYATANA_APP_INDICATOR_VERSION
+AYATANA_APP_INDICATOR_VERSION_S
+AYATANA_APP_INDICATOR_VERSION_HEX
+AYATANA_APP_INDICATOR_CHECK_VERSION
+</SECTION>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e5f591..b0990a8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -21,6 +21,11 @@ elseif (FLAVOUR_GTK2)
set (gtk_girver "Gtk-2.0")
endif()
+set(GIR_SOURCES
+ app-indicator.c
+ app-indicator.h
+)
+
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/app-indicator.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/lib${ayatana_appindicator_gtkver}-0.1/libayatana-appindicator")
# ayatana-appindicator{,3}-0.1.pc
@@ -132,16 +137,24 @@ install(TARGETS "${ayatana_appindicator_gtkver}" LIBRARY DESTINATION "${CMAKE_IN
# AyatanaAppIndicator{,3}-0.1.gir
+add_custom_command(
+ TARGET "${ayatana_appindicator_gtkver}" PRE_BUILD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND
+ ${CMAKE_COMMAND}
+ -E copy
+ ${GIR_SOURCES}
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
find_package(GObjectIntrospection REQUIRED)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${ayatana_appindicator_girver}-0.1.gir"
DEPENDS "${ayatana_appindicator_gtkver}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND
${INTROSPECTION_SCANNER}
- app-indicator.c ${HEADERS}
- --add-include-path=${CMAKE_CURRENT_BINARY_DIR}
+ ${GIR_SOURCES}
--c-include=libayatana-appindicator/app-indicator.h
--symbol-prefix=app
--identifier-prefix=App
@@ -173,3 +186,9 @@ add_custom_command(
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ayatana_appindicator_girver}-0.1.typelib" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/girepository-1.0")
add_custom_target(src ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${ayatana_appindicator_girver}-0.1.typelib")
+
+# app-indicator-version.h
+
+configure_file(app-indicator-version.h.in app-indicator-version.h @ONLY)
+
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/app-indicator-version.h" DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/lib${ayatana_appindicator_gtkver}-0.1/libayatana-appindicator")
diff --git a/src/app-indicator-version.h.in b/src/app-indicator-version.h.in
new file mode 100644
index 0000000..7d99c87
--- /dev/null
+++ b/src/app-indicator-version.h.in
@@ -0,0 +1,109 @@
+/*
+Copyright (C) 2021 Guido Berhoerster <guido+ayatana@berhoerster.name>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of either or both of the following licenses:
+
+1) the GNU Lesser General Public License version 3, as published by the
+ Free Software Foundation; and/or
+2) the GNU Lesser General Public License version 2.1, as published by
+ the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the applicable version of the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of both the GNU Lesser General Public
+License version 3 and version 2.1 along with this program. If not, see
+<http://www.gnu.org/licenses/>
+*/
+
+#ifndef APP_INDICATOR_VERSION_H
+#define APP_INDICATOR_VERSION_H
+
+#if !defined(APP_INDICATOR_INSIDE) && !defined(APP_INDICATOR_COMPILATION)
+#error "Only <app-indicator.h> can be included directly."
+#endif
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION:app-indicator-version
+ * @Title: Versioning
+ * @short_description: Ayatana Application Indicators version checking
+ *
+ * ayatana-appindicator provides macros for checking the version of the library
+ * an application is compiled against.
+ */
+
+/**
+ * AYATANA_APP_INDICATOR_MAJOR_VERSION:
+ *
+ * Ayatana Application Indicators major version component (e.g. 1 if
+ * %AYATANA_APP_INDICATOR_VERSION is 1.2.3)
+ */
+#define AYATANA_APP_INDICATOR_MAJOR_VERSION (@PROJECT_VERSION_MAJOR@)
+
+/**
+ * AYATANA_APP_INDICATOR_MINOR_VERSION:
+ *
+ * Ayatana Application Indicators minor version component (e.g. 2 if
+ * %AYATANA_APP_INDICATOR_VERSION is 1.2.3)
+ */
+#define AYATANA_APP_INDICATOR_MINOR_VERSION (@PROJECT_VERSION_MINOR@)
+
+/**
+ * AYATANA_APP_INDICATOR_MICRO_VERSION:
+ *
+ * Ayatana Application Indicators micro version component (e.g. 3 if
+ * %AYATANA_APP_INDICATOR_VERSION is 1.2.3)
+ */
+#define AYATANA_APP_INDICATOR_MICRO_VERSION (@PROJECT_VERSION_PATCH@)
+
+/**
+ * AYATANA_APP_INDICATOR_VERSION
+ *
+ * Ayatana Application Indicators version, e.g. 1.2.3.
+ */
+#define AYATANA_APP_INDICATOR_VERSION (@PROJECT_VERSION@)
+
+/**
+ * AYATANA_APP_INDICATOR_VERSION_S:
+ *
+ * Ayatana Application Indicators version, encoded as a string which may be
+ * concatenated, e.g. "1.2.3".
+ */
+#define AYATANA_APP_INDICATOR_VERSION_S "@PROJECT_VERSION@"
+
+#define AYATANA_APP_INDICATOR_ENCODE_VERSION(major,minor,micro) \
+ ((major) << 24 | (minor) << 16 | (micro) << 8)
+
+/**
+ * AYATANA_APP_INDICATOR_VERSION_HEX:
+ *
+ * Ayatana Application Indicators version, encoded as an hexadecimal number
+ * which may be compared to an integer number, e.g. 0x010203.
+ */
+#define AYATANA_APP_INDICATOR_VERSION_HEX \
+ (AYATANA_APP_INDICATOR_ENCODE_VERSION (AYATANA_APP_INDICATOR_MAJOR_VERSION, AYATANA_APP_INDICATOR_MINOR_VERSION, AYATANA_APP_INDICATOR_MICRO_VERSION))
+
+/**
+ * AYATANA_APP_INDICATOR_CHECK_VERSION:
+ * @major: required major version
+ * @minor: required minor version
+ * @micro: required micro version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version of
+ * ayatana-appindicator is greater than the given @major, @minor, and @micro
+ * numbers.
+ */
+#define AYATANA_APP_INDICATOR_CHECK_VERSION(major,minor,micro) \
+ (AYATANA_APP_INDICATOR_MAJOR_VERSION > (major) || \
+ (AYATANA_APP_INDICATOR_MAJOR_VERSION == (major) && AYATANA_APP_INDICATOR_MINOR_VERSION > (minor)) || \
+ (AYATANA_APP_INDICATOR_MAJOR_VERSION == (major) && AYATANA_APP_INDICATOR_MINOR_VERSION == (minor) && AYATANA_APP_INDICATOR_MICRO_VERSION >= (micro)))
+
+G_END_DECLS
+
+#endif /* APP_INDICATOR_VERSION_H */
diff --git a/src/app-indicator.h b/src/app-indicator.h
index b53b7fd..4ac78f4 100644
--- a/src/app-indicator.h
+++ b/src/app-indicator.h
@@ -32,6 +32,10 @@ License version 3 and version 2.1 along with this program. If not, see
#include <gtk/gtk.h>
+#define APP_INDICATOR_INSIDE
+#include "app-indicator-version.h"
+#undef APP_INDICATOR_INSIDE
+
G_BEGIN_DECLS
/**