Skip to content

Commit aecfc43

Browse files
authored
Merge pull request #228 from aglowacki/master
Added git tag and hash version
2 parents 28e1fda + af347ff commit aecfc43

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,35 @@ option(AVX "Compule with arch AVX on MSVC" OFF)
8989
option(SSE2 "Compule with arch SSE2 on MSVC" OFF)
9090
option(MSVC_DEBUG_INFO_REL "Compule with debug info in Release build for MSVC" OFF)
9191

92+
93+
94+
# generate_git_hash_header.cmake
95+
# This script is run by add_custom_command to generate the header file.
96+
97+
# Get the Git commit hash
98+
execute_process(
99+
COMMAND git rev-parse HEAD
100+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
101+
OUTPUT_VARIABLE GIT_HASH
102+
OUTPUT_STRIP_TRAILING_WHITESPACE
103+
)
104+
105+
execute_process(
106+
COMMAND git describe --exact-match --tags
107+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
108+
OUTPUT_VARIABLE GIT_TAG
109+
OUTPUT_STRIP_TRAILING_WHITESPACE
110+
)
111+
112+
# Define the header content
113+
set(HEADER_CONTENT "#pragma once\n")
114+
string(APPEND HEADER_CONTENT "#define GIT_COMMIT_HASH \"${GIT_HASH}\"\n")
115+
string(APPEND HEADER_CONTENT "#define GIT_COMMIT_TAG \"${GIT_TAG}\"\n")
116+
117+
# Write the content to the header file
118+
file(WRITE "${CMAKE_SOURCE_DIR}/src/core/git_hash.h" "${HEADER_CONTENT}")
119+
120+
92121
# Opitons for getting YouCompleteMe plugin working with this project
93122
SET( CMAKE_EXPORT_COMPILE_COMMANDS ON )
94123

src/core/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
4949
#include "core/process_streaming.h"
5050
#include "core/process_whole.h"
5151
#include <cctype>
52+
#include "core/git_hash.h"
5253

5354

5455
#define MAX_DETECTORS 7
@@ -92,7 +93,7 @@ void help()
9293
logit_s<<" matrix : Fit with locked parameters \n\n";
9394
logit_s<<"Dataset: "<<"\n";
9495
logit_s<<"--dir : Dataset directory \n";
95-
logit_s<<"--files : Dataset files: comma (',') separated if multiple \n";
96+
logit_s<<"--files : Dataset files: comma (',') separated if multiple \n";
9697
#ifdef _BUILD_WITH_ZMQ
9798
logit_s<<"Network: \n";
9899
logit_s<<"--streamin [source ip] : Accept a ZMQ stream of spectra to process. Source ip defaults to localhost (must compile with -DBUILD_WITH_ZMQ option) \n";
@@ -945,6 +946,7 @@ int run_h5_file_updates(Command_Line_Parser& clp)
945946
int main(int argc, char* argv[])
946947
{
947948

949+
logI << "Version: " << GIT_COMMIT_TAG << " Git Hash: " << GIT_COMMIT_HASH << "\n";
948950
std::string whole_command_line = "";
949951
for (int i = 0; i < argc; i++)
950952
{

0 commit comments

Comments
 (0)