From 32235ca60a111cbea5f0cbed0cb8e5655c71b169 Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Mon, 17 Jan 2011 23:27:38 +0100 Subject: [PATCH] CMake - improve compilation by removing the git sha1 dependency into its own include file that is just used 2 times instead of auto.h that is included in more places. --- .gitignore | 1 + CMakeLists.txt | 2 ++ cmake.h.in | 1 - commit.h.in | 4 ++++ src/command.cpp | 5 ++++- src/diag.cpp | 3 +++ 6 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 commit.h.in diff --git a/.gitignore b/.gitignore index bd5fbcd07..37e8df60e 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ install_manifest.txt _CPack_Packages CPackConfig.cmake CPackSourceConfig.cmake +commit.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c267c53..558e9c51c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ if (EXISTS .git/index) set (HAVE_COMMIT true) execute_process (COMMAND git log -1 --pretty=format:%h OUTPUT_VARIABLE COMMIT) + configure_file ( ${CMAKE_SOURCE_DIR}/commit.h.in + ${CMAKE_SOURCE_DIR}/commit.h) message ("-- Found SHA1 reference: ${COMMIT}") endif (EXISTS .git/index) diff --git a/cmake.h.in b/cmake.h.in index 12209a192..5a5cc817d 100644 --- a/cmake.h.in +++ b/cmake.h.in @@ -11,7 +11,6 @@ /* git information */ #cmakedefine HAVE_COMMIT -#define COMMIT "${COMMIT}" /* Compiling platform */ #cmakedefine LINUX diff --git a/commit.h.in b/commit.h.in new file mode 100644 index 000000000..3a6fe82de --- /dev/null +++ b/commit.h.in @@ -0,0 +1,4 @@ +/* commit.h.in. Creates commit.h during a cmake run */ + +/* git information */ +#define COMMIT "${COMMIT}" diff --git a/src/command.cpp b/src/command.cpp index c89c1f864..9c2453f5c 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -42,8 +42,11 @@ #include "text.h" #include "util.h" #include "main.h" -#include "../auto.h" #include "Transport.h" +#include "../auto.h" +#ifdef HAVE_COMMIT +#include "../commit.h" +#endif extern Context context; diff --git a/src/diag.cpp b/src/diag.cpp index c7b68d222..1e2621e9b 100644 --- a/src/diag.cpp +++ b/src/diag.cpp @@ -39,6 +39,9 @@ #include #include #include "../auto.h" +#ifdef HAVE_COMMIT +#include "../commit.h" +#endif #ifdef HAVE_LIBLUA extern "C"