From ad772edc39878283a1cf90f87d0eadd84b88454c Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 26 Nov 2016 15:30:08 +0100 Subject: [PATCH] fix(build): Update version on configure --- .gitignore | 2 +- include/config.hpp.cmake | 6 +++++- src/CMakeLists.txt | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0b46550e..8e3a5a21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build*/ +/build*/ !cmake/build/ tags *.bak diff --git a/include/config.hpp.cmake b/include/config.hpp.cmake index 4f456c9c..03cf8361 100644 --- a/include/config.hpp.cmake +++ b/include/config.hpp.cmake @@ -6,6 +6,10 @@ #include "version.hpp" #define APP_NAME "@PROJECT_NAME@" +#cmakedefine APP_VERSION "@APP_VERSION@" +#ifndef APP_VERSION +#define APP_VERSION GIT_TAG +#endif #define BASE_PATH "@PROJECT_SOURCE_DIR@" #cmakedefine01 ENABLE_ALSA @@ -52,7 +56,7 @@ auto version_details = [](const std::vector& args) { // clang-format off auto print_build_info = [](bool extended = false) { - std::cout << APP_NAME << " " << GIT_TAG << " " << "\n" + std::cout << APP_NAME << " " << APP_VERSION << " " << "\n" << "\n" << "Features: " << (ENABLE_ALSA ? "+" : "-") << "alsa " diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcb1baea..29b3ae3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,11 @@ # Create executable # +execute_process(COMMAND git describe --tags --dirty=-git + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE APP_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) + configure_file( ${PROJECT_SOURCE_DIR}/include/config.hpp.cmake ${CMAKE_SOURCE_DIR}/include/config.hpp