Skip to content

Commit

Permalink
Add option to suppress git hash in version info
Browse files Browse the repository at this point in the history
  • Loading branch information
godotalgorithm committed Nov 10, 2024
1 parent 8ddf712 commit 092d232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,13 @@ endif()

# Pass version & commit information to MOPAC's Fortran source
target_compile_definitions(mopac-core PRIVATE MOPAC_VERSION_FULL="${PROJECT_VERSION}")
if(NOT GIT_HASH)
execute_process(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_HASH)
endif()
option(GIT_HASH "Enable THREADS keyword using OpenMP API" ON)
if(GIT_HASH)
string(STRIP ${GIT_HASH} GIT_HASH)
target_compile_definitions(mopac-core PRIVATE MOPAC_GIT_HASH="${GIT_HASH}")
execute_process(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_HASH_VAL)
if(GIT_HASH_VAL)
string(STRIP ${GIT_HASH_VAL} GIT_HASH_VAL)
target_compile_definitions(mopac-core PRIVATE MOPAC_GIT_HASH="${GIT_HASH_VAL}")
endif()
endif()

# Try to use CMake's system of finding BLAS & LAPACK libraries
Expand Down
4 changes: 4 additions & 0 deletions src/run_mopac.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ subroutine run_mopac
call getarg (i, jobnam)
#endif
if (jobnam == '-V' .OR. jobnam == '--version') then
#ifdef MOPAC_GIT_HASH
write(*,"(a)") "MOPAC version "//trim(verson)//" commit "//trim(git_hash)
#else
write(*,"(a)") "MOPAC version "//trim(verson)
#endif
stop
endif
end do
Expand Down

0 comments on commit 092d232

Please sign in to comment.