Skip to content
Snippets Groups Projects
Commit 1b792f26 authored by Chiara Salvoni's avatar Chiara Salvoni
Browse files

Merge branch 'ast-1430-print-commit-hash' into 'master'

AST-1430: add comit hash to cmake file

See merge request RD/DP3!1234
parents 90fcd10e d3edb869
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,13 @@ else()
message(FATAL_ERROR "Failed to parse DP3_VERSION='${DP3_VERSION}'")
endif()
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git describe
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE DP3_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
option(BUILD_WITH_CUDA "Build with CUDA support" FALSE)
if(BUILD_WITH_CUDA)
project(
......
......@@ -47,7 +47,7 @@ int main(int argc, char* argv[]) {
showUsage();
return 0;
} else if (param == "-v" || param == "--version") {
std::cout << DP3Version::AsString() << '\n';
std::cout << DP3Version::AsString(true) << '\n';
return 0;
}
}
......
......@@ -11,11 +11,19 @@
#define DP3_INSTALL_PATH "@CMAKE_INSTALL_PREFIX@"
#define DP3_COMMIT_HASH "@DP3_GIT_HASH@"
#include <string>
class DP3Version {
public:
static std::string AsString() { return "DP3 " + std::string(DP3_VERSION); }
static std::string AsString(bool add_commit_hash = false) {
std::string version = "DP3 " + std::string(DP3_VERSION);
std::string commit_hash = std::string(DP3_COMMIT_HASH).empty()
? "Commit hash undefined"
: std::string(DP3_COMMIT_HASH);
return add_commit_hash ? version + "\n" + commit_hash : version;
}
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment