From b7428ac42dcb7e560f60a1219325600399d5a15a Mon Sep 17 00:00:00 2001 From: Anupama Rajendra Date: Wed, 12 Aug 2026 16:06:09 -0500 Subject: [PATCH 1/4] print git hash to output --- CMakeLists.txt | 11 ++++++++++- FindGitHash.cmake | 11 +++++++++++ src/CMakeLists.txt | 6 ++++++ src/alara.C | 4 +++- src/config.h.in | 2 ++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 FindGitHash.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e2fa99f..e95f250a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,15 @@ set(PACKAGE_STRING "ALARA ${PACKAGE_VERSION}") set(DFLT_DATADIR ${CMAKE_INSTALL_PREFIX}/data) set(DFLT_XSDIR ${CMAKE_INSTALL_PREFIX}/data) +set(GIT_HASH_HEADER "${CMAKE_CURRENT_BINARY_DIR}/git_hash.h") + +add_custom_target(update_git_hash ALL + COMMAND ${CMAKE_COMMAND} + -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + -DOUTPUT_FILE=${GIT_HASH_HEADER} + -P ${CMAKE_CURRENT_SOURCE_DIR}/FindGitHash.cmake +) + # Build ALARA executable add_subdirectory(src) @@ -26,4 +35,4 @@ add_subdirectory(tools) add_subdirectory(data) # Install sample files -add_subdirectory(sample) +add_subdirectory(sample) \ No newline at end of file diff --git a/FindGitHash.cmake b/FindGitHash.cmake new file mode 100644 index 00000000..a265cce7 --- /dev/null +++ b/FindGitHash.cmake @@ -0,0 +1,11 @@ +execute_process( + COMMAND git log -1 --format=%H + WORKING_DIRECTORY "${SOURCE_DIR}" + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +file(WRITE "${OUTPUT_FILE}" + "#pragma once\n" + "#define GIT_COMMIT_HASH \"${GIT_COMMIT_HASH}\"\n" +) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47e7306c..0117b8fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,13 @@ configure_file(dflt_datadir.h.in dflt_datadir.h) # Location of header files include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_BINARY_DIR}) # ALARA executable add_executable(alara ${SRC_FILES}) install(TARGETS alara DESTINATION bin) + +# Make sure the Git hash is generated before compiling ALARA +add_dependencies(alara update_git_hash) + +install(TARGETS alara DESTINATION bin) diff --git a/src/alara.C b/src/alara.C index 5c007c8f..aaed033e 100644 --- a/src/alara.C +++ b/src/alara.C @@ -1,6 +1,6 @@ /* $Id: alara.C,v 1.20 2004-07-29 19:24:10 wilsonp Exp $ */ #include "alara.h" - +#include "git_hash.h" #include "Input.h" #include "Root.h" #include "Statistics.h" @@ -181,6 +181,8 @@ int main(int argc, char *argv[]) Input problemInput(inFname); /* INPUT */ + verbose(-1, "The version of ALARA used to run this simulation was built with Git commit: %s", GIT_COMMIT_HASH); + ///verbose(-1, "The version of ALARA used to run this simulation was built with a Git commit made on: %s", GIT_COMMIT_DATE); verbose(0,"Starting problem input processing."); verbose(1,"Reading input."); problemInput.read(); diff --git a/src/config.h.in b/src/config.h.in index c8b86ac4..98bc137c 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1 +1,3 @@ #define PACKAGE_STRING "${PACKAGE_STRING}" +#define GIT_COMMIT_HASH "${GIT_COMMIT_HASH}" +#define GIT_COMMIT_DATE "${GIT_COMMIT_DATE}" From 7c8454f32d612d380afa2021cee72bc055c8ba50 Mon Sep 17 00:00:00 2001 From: Anupama Rajendra Date: Wed, 12 Aug 2026 16:08:43 -0500 Subject: [PATCH 2/4] remove unused variable --- src/config.h.in | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.h.in b/src/config.h.in index 98bc137c..cbbbc225 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,3 +1,2 @@ #define PACKAGE_STRING "${PACKAGE_STRING}" #define GIT_COMMIT_HASH "${GIT_COMMIT_HASH}" -#define GIT_COMMIT_DATE "${GIT_COMMIT_DATE}" From 92e2b6f335caec95c73d7de46a97181226b4f35b Mon Sep 17 00:00:00 2001 From: Anupama Rajendra Date: Wed, 12 Aug 2026 16:29:59 -0500 Subject: [PATCH 3/4] remove commented line --- src/alara.C | 1 - 1 file changed, 1 deletion(-) diff --git a/src/alara.C b/src/alara.C index aaed033e..8fcc7d27 100644 --- a/src/alara.C +++ b/src/alara.C @@ -182,7 +182,6 @@ int main(int argc, char *argv[]) /* INPUT */ verbose(-1, "The version of ALARA used to run this simulation was built with Git commit: %s", GIT_COMMIT_HASH); - ///verbose(-1, "The version of ALARA used to run this simulation was built with a Git commit made on: %s", GIT_COMMIT_DATE); verbose(0,"Starting problem input processing."); verbose(1,"Reading input."); problemInput.read(); From 13f98a83cbf1b124f1da48b216fd52f70bf1f249 Mon Sep 17 00:00:00 2001 From: Anupama Rajendra Date: Wed, 12 Aug 2026 17:02:03 -0500 Subject: [PATCH 4/4] remove redundant installation command --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0117b8fd..13304d61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ include_directories(${CMAKE_BINARY_DIR}) # ALARA executable add_executable(alara ${SRC_FILES}) -install(TARGETS alara DESTINATION bin) # Make sure the Git hash is generated before compiling ALARA add_dependencies(alara update_git_hash)