diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-19 12:44:55 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-12-19 12:44:55 -0500 |
commit | 5f9462caad014e4abfc762101c8d2e6b02bb1ae5 (patch) | |
tree | 7662550a895bedb1aefdf91b6029c5068fa082df | |
parent | 210bf43679532b99d9628b66977601856195c849 (diff) | |
download | spmc-versioning.tar.gz |
Print versionversioning
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | config.h.in | 1 | ||||
-rw-r--r-- | src/spm.c | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ee2fded..a833b85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,18 @@ cmake_minimum_required(VERSION 3.15) project(spm C) include(CheckSymbolExists) +find_package(Git) set(CMAKE_C_STANDARD 99) - +execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty + OUTPUT_VARIABLE VERSION + ERROR_VARIABLE VERSION_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE +) +if(${VERSION_ERROR}) + message("Git required to build this software") + return(1) +endif(${VERSION_ERROR}) check_symbol_exists(strsep string.h HAVE_STRSEP) configure_file(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/include/config.h) diff --git a/config.h.in b/config.h.in index cedd8a4..b9fd475 100644 --- a/config.h.in +++ b/config.h.in @@ -2,5 +2,6 @@ #define SPM_CONFIG_IN_H #cmakedefine HAVE_STRSEP 1 +#define SPM_VERSION "${VERSION}" #endif //SPM_CONFIG_IN_H @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) { exit(0); } else if (strcmp(arg, "-V") == 0 || strcmp(arg, "--version") == 0) { - printf("want version\n"); + printf("%s\n", SPM_VERSION); exit(0); } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0) { |