Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -26,4 +35,4 @@ add_subdirectory(tools)
add_subdirectory(data)

# Install sample files
add_subdirectory(sample)
add_subdirectory(sample)
11 changes: 11 additions & 0 deletions FindGitHash.cmake
Original file line number Diff line number Diff line change
@@ -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"
)
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ 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})

# Make sure the Git hash is generated before compiling ALARA
add_dependencies(alara update_git_hash)

install(TARGETS alara DESTINATION bin)
3 changes: 2 additions & 1 deletion src/alara.C
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -181,6 +181,7 @@ 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(0,"Starting problem input processing.");
verbose(1,"Reading input.");
problemInput.read();
Expand Down
1 change: 1 addition & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#define PACKAGE_STRING "${PACKAGE_STRING}"
#define GIT_COMMIT_HASH "${GIT_COMMIT_HASH}"
Loading