diff --git a/CMakeLists.txt b/CMakeLists.txt
index e179eacbf6305908aeecc13a442f54f2333604d6..82814202dc49f099020afa4af3c9d14a99d3694f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/gen_OPALrevision b/gen_OPALrevision
new file mode 100644
index 0000000000000000000000000000000000000000..2f7bfd1f20b676ba1faf1df9f30bb2587d9b5785
--- /dev/null
+++ b/gen_OPALrevision
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# rewritting 'src/OPALrevision.h'
+# if a git binary is in $PATH and we are in a Git work tree; then
+#     write the Git revision
+# if
+#   (a git binary does not exist in $PATH or we are in a Git work tree)
+#   and the file does not exist; then write "unknown" 
+#
+
+function print {
+    echo '#define GIT_VERSION '\"$1\" > src/OPALrevision.h
+    exit $?
+}
+
+which -a git &> /dev/null || print unknown
+
+if git rev-parse --is-inside-work-tree &> /dev/null; then
+    revision=$(git rev-parse HEAD)
+    print ${revision}
+elif [[ ! -e  src/OPALrevision.h ]]; then
+    print unknown
+fi
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f8dede18a227206dc0a57a8d04d9a6c0387847f7..b4564c5c441e1aeb5c21a0d8b4126b142eebc972 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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 )
diff --git a/src/revision.h.in b/src/revision.h.in
deleted file mode 100644
index fb099b41ab286cd3e0e34bc5fdaea90f510fdd90..0000000000000000000000000000000000000000
--- a/src/revision.h.in
+++ /dev/null
@@ -1 +0,0 @@
-#define GIT_VERSION ${OPAL_WC_REVISION}