diff --git a/cmake/git_version.cmake b/cmake/git_version.cmake index 471ae6adcf9a38ff81793ebc26576dc24172b646..2b850ab4f73ba5f3f3d461c0de8a807a890036f3 100644 --- a/cmake/git_version.cmake +++ b/cmake/git_version.cmake @@ -8,6 +8,14 @@ if (Git_FOUND) WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" RESULT_VARIABLE GIT_RESULT OUTPUT_VARIABLE VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND + "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + RESULT_VARIABLE GIT_RESULT + OUTPUT_VARIABLE BRANCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) diff --git a/components/common/cpp/include/ftl/config.h.in b/components/common/cpp/include/ftl/config.h.in index 779918c144c4355a0ed81c382fb23af8e6e3235b..5dcc8e5758c577e56850323d95a3d8aadf915573 100644 --- a/components/common/cpp/include/ftl/config.h.in +++ b/components/common/cpp/include/ftl/config.h.in @@ -22,6 +22,7 @@ #cmakedefine HAVE_NANOGUI #cmakedefine HAVE_LIBARCHIVE +extern const char *FTL_BRANCH; extern const char *FTL_VERSION_LONG; extern const char *FTL_VERSION; extern const int FTL_VERSION_MAJOR; diff --git a/components/common/cpp/src/config.cpp.in b/components/common/cpp/src/config.cpp.in index 15d1bbc11f7254a0eef6852d449a6110b6841607..fb0aadd4cb6f22b640bd9ca3cdf885b512efcc79 100644 --- a/components/common/cpp/src/config.cpp.in +++ b/components/common/cpp/src/config.cpp.in @@ -1,5 +1,6 @@ #include <ftl/config.h> +const char *FTL_BRANCH = "@BRANCH@"; const char *FTL_VERSION_LONG = "@VERSION@"; const char *FTL_VERSION = ""; const int FTL_VERSION_MAJOR = 0; diff --git a/components/common/cpp/src/configuration.cpp b/components/common/cpp/src/configuration.cpp index af8bbd6556a66f0bb63a3d611d566a1f3ab4e566..dc6e59b977412729dd658de6fb49238b5c39cdfa 100644 --- a/components/common/cpp/src/configuration.cpp +++ b/components/common/cpp/src/configuration.cpp @@ -49,7 +49,7 @@ static Configurable *rootCFG = nullptr; bool ftl::running = true; int ftl::exit_code = 0; -std::string ftl::branch_name = ""; +std::string ftl::branch_name = FTL_BRANCH; bool ftl::is_directory(const std::string &path) { #ifdef WIN32