summaryrefslogtreecommitdiffstats
path: root/libversion
diff options
context:
space:
mode:
Diffstat (limited to 'libversion')
-rw-r--r--libversion/CMakeLists.txt27
-rw-r--r--libversion/doxyversion.cpp.in7
-rw-r--r--libversion/gitversion.cpp.in16
-rw-r--r--libversion/version.h22
4 files changed, 72 insertions, 0 deletions
diff --git a/libversion/CMakeLists.txt b/libversion/CMakeLists.txt
new file mode 100644
index 0000000..1a430fd
--- /dev/null
+++ b/libversion/CMakeLists.txt
@@ -0,0 +1,27 @@
+# vim:ts=4:sw=4:expandtab:autoindent:
+
+# setup information for doxygen version handling
+set(PRE_CONFIGURE_DOXYGEN_VERSION_FILE "${CMAKE_SOURCE_DIR}/libversion/doxyversion.cpp.in")
+set(POST_CONFIGURE_DOXYGEN_VERSION_FILE "${GENERATED_SRC}/doxyversion.cpp")
+
+# setup information for git version handling
+set(PRE_CONFIGURE_GIT_VERSION_FILE "${CMAKE_SOURCE_DIR}/libversion/gitversion.cpp.in")
+set(POST_CONFIGURE_GIT_VERSION_FILE "${GENERATED_SRC}/gitversion.cpp")
+
+include(${CMAKE_SOURCE_DIR}/cmake/git_watcher.cmake)
+include(${CMAKE_SOURCE_DIR}/cmake/doxygen_version.cmake)
+
+include_directories(
+ .
+)
+
+add_library(version STATIC
+ ${POST_CONFIGURE_DOXYGEN_VERSION_FILE}
+ ${POST_CONFIGURE_GIT_VERSION_FILE}
+)
+
+add_dependencies( version check_git_repository )
+add_dependencies( version check_doxygen_version )
+
+set_source_files_properties(${POST_CONFIGURE_GIT_VERSION_FILE} PROPERTIES GENERATED 1)
+set_source_files_properties(${POST_CONFIGURE_DOXYGEN_VERSION_FILE} PROPERTIES GENERATED 1)
diff --git a/libversion/doxyversion.cpp.in b/libversion/doxyversion.cpp.in
new file mode 100644
index 0000000..11bca8d
--- /dev/null
+++ b/libversion/doxyversion.cpp.in
@@ -0,0 +1,7 @@
+#include "version.h"
+
+char *getVersion(void)
+{
+ static char versionString[] = "@DOXYGEN_VERSION@";
+ return versionString;
+}
diff --git a/libversion/gitversion.cpp.in b/libversion/gitversion.cpp.in
new file mode 100644
index 0000000..164b50b
--- /dev/null
+++ b/libversion/gitversion.cpp.in
@@ -0,0 +1,16 @@
+#include <string.h>
+#include <version.h>
+
+/* - On some systems git is not installed or
+ * installed on a place where FindGit.cmake cannot find it
+ * - No git information is present (no .git directory)
+ * in those cases clear the gitVersionString (would have string GIT-NOTFOUND).
+ */
+char *getGitVersion(void)
+{
+ static char gitVersionString[100];
+ strcpy(gitVersionString,"@GIT_HEAD_SHA1@");
+ strcat(gitVersionString,!strcmp("@GIT_IS_DIRTY@","true")?"*":"");
+ if (!strcmp("@GIT_HEAD_SHA1@", "GIT-NOTFOUND")) gitVersionString[0] = '\0';
+ return gitVersionString;
+}
diff --git a/libversion/version.h b/libversion/version.h
new file mode 100644
index 0000000..a656e74
--- /dev/null
+++ b/libversion/version.h
@@ -0,0 +1,22 @@
+/******************************************************************************
+ *
+ *
+ *
+ * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ *
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+char *getVersion(void);
+char *getGitVersion(void);
+#endif