mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Define GIT_SHA1 in header file.
This commit is contained in:
parent
0c5234e984
commit
c54a3463d4
3 changed files with 20 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,6 +4,7 @@
|
|||
*.mod
|
||||
*.log
|
||||
*.out
|
||||
git_sha1.h
|
||||
|
||||
# Compiler python objects
|
||||
*.pyc
|
||||
|
|
|
|||
|
|
@ -137,6 +137,24 @@ if(petsc)
|
|||
set(libraries "${PETSC_PACKAGE_LIBS};${libpetsc};${libraries}")
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# git SHA1 hash
|
||||
#===============================================================================
|
||||
|
||||
execute_process(COMMAND git log -1
|
||||
COMMAND head -n 1
|
||||
COMMAND cut -c8-
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GIT_SHA1_SUCCESS
|
||||
OUTPUT_VARIABLE GIT_SHA1
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(GIT_SHA1_SUCCESS EQUAL 0)
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.h
|
||||
"#define GIT_SHA1 \"${GIT_SHA1}\"")
|
||||
else()
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.h "")
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# FoX Fortran XML Library
|
||||
#===============================================================================
|
||||
|
|
@ -154,7 +172,6 @@ add_executable(${program} ${source})
|
|||
target_link_libraries(${program} ${libraries} fox)
|
||||
set_target_properties(${program} PROPERTIES
|
||||
COMPILE_FLAGS "${f90flags}"
|
||||
COMPILE_DEFINITIONS "${definitions}"
|
||||
LINK_FLAGS "${ldflags}")
|
||||
|
||||
#===============================================================================
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ contains
|
|||
' License: http://mit-crpg.github.io/openmc/license.html'
|
||||
write(UNIT=OUTPUT_UNIT, FMT='(6X,"Version:",8X,I1,".",I1,".",I1)') &
|
||||
VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE
|
||||
#include "git_sha1.h"
|
||||
#ifdef GIT_SHA1
|
||||
write(UNIT=OUTPUT_UNIT, FMT='(6X,"Git SHA1:",7X,A)') GIT_SHA1
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue