Commit 0b4aeaa2 authored by gsell's avatar gsell
Browse files

Merge branch '346-better-solution-to-create-update-src-opalrevision-h-3' into 'master'

Resolve "better solution to create/update src/OPALrevision.h"

Closes #346

See merge request !381
parents 49516309 257a134f
......@@ -222,19 +222,18 @@ endif ()
option (ENABLE_DOXYDOC "compile Doxygen documentation" OFF)
include (FindGit)
if (GIT_FOUND)
set (OPAL_WC_REVISION 0)
execute_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
set (OPAL_WC_REVISION \"${GIT_OUT}\")
else ()
message (STATUS "could not find git")
set (OPAL_WC_REVISION \"\")
endif ()
add_custom_target(always_rebuild ALL
DEPENDS
src/OPALrevision.h
)
add_custom_command(
OUTPUT src/OPALrevision.h
COMMAND ./gen_OPALrevision
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS
always_rebuild
)
add_subdirectory (ippl)
add_subdirectory (optimizer)
......
#!/bin/bash
#
# create/rewrite 'src/OPALrevision.h'
#
print () {
echo '#define GIT_VERSION '\"$1\" > src/OPALrevision.h
}
# if git(1) is not in $PATH
if ! which -a git &> /dev/null; then
if [[ -e src/OPALrevision.h ]]; then
# do nothing if file exist
exit 0
else
# otherwise create file
print unknown
exit $?
fi
fi
# if we are in a work-tree
if git rev-parse --is-inside-work-tree &> /dev/null; then
# create/rewrite file
revision=$(git rev-parse HEAD)
print ${revision}
exit $?
fi
# if we are not in a work tree and the file does not exist
if [[ ! -e src/OPALrevision.h ]]; then
# create file
print unknown
exit $?
fi
exit 0
\ No newline at end of file
......@@ -30,7 +30,6 @@ else ()
endif ()
configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/OPALconfig.h)
configure_file(revision.h.in ${CMAKE_CURRENT_SOURCE_DIR}/OPALrevision.h)
set (OPAL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set (OPAL_SRCS )
......
#define GIT_VERSION ${OPAL_WC_REVISION}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment