From c85375c322385b5b1bdb269b71d5786d0c1f61a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Sun, 11 Mar 2018 02:21:04 +0100 Subject: [PATCH] Improved git revision management --- CMakeLists.txt | 10 +++++++--- git_revision.hpp.in | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 git_revision.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 89279af51..cca6ca8fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,9 +38,13 @@ get_git_head_revision(GITREV GITHASH) git_local_changes(GITHASLOCALCHANGES) message("git rev ${GITREV} : ${GITHASH} (${GITHASLOCALCHANGES})") -file(WRITE "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITREV \"${GITREV}\"\n") -file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITHASH \"${GITHASH}\"\n") -file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp" "#define GITHASLOCALCHANGES \"${GITHASLOCALCHANGES}\"\n") +#file(WRITE "${CMAKE_BINARY_DIR}/git_revision.hpp.in" "#define GITREV \"${GITREV}\"\n") +#file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp.in" "#define GITHASH \"${GITHASH}\"\n") +#file(APPEND "${CMAKE_BINARY_DIR}/git_revision.hpp.in" "#define GITHASLOCALCHANGES \"${GITHASLOCALCHANGES}\"\n") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.hpp") + +list(APPEND SOURCES git_revision.hpp) include_directories(${CMAKE_BINARY_DIR}) diff --git a/git_revision.hpp.in b/git_revision.hpp.in new file mode 100644 index 000000000..86b65c4ad --- /dev/null +++ b/git_revision.hpp.in @@ -0,0 +1,3 @@ +#define GITREV "@GITREV@" +#define GITHASH "@GITHASH@" +#define GITHASLOCALCHANGES "@GITHASLOCALCHANGES@" -- GitLab