From 7f9a25a30d77198ae4347075206c62c755f54372 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 27 Aug 2021 09:20:47 +0200 Subject: [PATCH] add: get version from libspandisc --- libs/spandisc/CMakeLists.txt | 3 +++ libs/spandisc/include/config.h.in | 6 ++++++ libs/spandisc/include/logic.h | 2 ++ libs/spandisc/src/logic.c | 6 ++++++ src/discspan.c | 1 + 5 files changed, 18 insertions(+) create mode 100644 libs/spandisc/include/config.h.in diff --git a/libs/spandisc/CMakeLists.txt b/libs/spandisc/CMakeLists.txt index a697c83..c9aad11 100644 --- a/libs/spandisc/CMakeLists.txt +++ b/libs/spandisc/CMakeLists.txt @@ -12,6 +12,9 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT option(BUILD_SHARED_LIBS "build shared libs" ON) +configure_file(include/config.h.in include/config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) + file(GLOB SOURCES src/*.c) file(GLOB PUBLIC_HEADER include/*.h) include_directories(include) diff --git a/libs/spandisc/include/config.h.in b/libs/spandisc/include/config.h.in new file mode 100644 index 0000000..33ec557 --- /dev/null +++ b/libs/spandisc/include/config.h.in @@ -0,0 +1,6 @@ +#ifndef SPANDISC_CONFIG_IN_H +#define SPANDISC_CONFIG_IN_H + +#define VERSION "@PROJECT_VERSION@" + +#endif diff --git a/libs/spandisc/include/logic.h b/libs/spandisc/include/logic.h index 6e5ae95..40b70f6 100644 --- a/libs/spandisc/include/logic.h +++ b/libs/spandisc/include/logic.h @@ -1,6 +1,8 @@ #ifndef _LOGIC_H #define _LOGIC_H +const char *get_version(); + /** * Event pointer to method execute by the writing file. * This Method is called by span diff --git a/libs/spandisc/src/logic.c b/libs/spandisc/src/logic.c index df3eb28..98ca8b5 100644 --- a/libs/spandisc/src/logic.c +++ b/libs/spandisc/src/logic.c @@ -2,6 +2,7 @@ #include #include +#include "config.h" #include "spandisc.h" #include "logic.h" #include "splitter.h" @@ -9,6 +10,11 @@ status_print_t status_print = NULL; +const char * get_version() +{ + return VERSION; +} + void on_status_print(const char *output, medium_t disc) { if (status_print != NULL) diff --git a/src/discspan.c b/src/discspan.c index 4bf7511..0b4dd27 100644 --- a/src/discspan.c +++ b/src/discspan.c @@ -16,6 +16,7 @@ typedef struct { void show_version() { printf("discspan %s\n", VERSION); + printf("libspandisc %s\n", get_version()); } param_t read_argument(int argc, char *argv[]) -- 2.39.5