summaryrefslogtreecommitdiffhomepage
path: root/cmake/opentrack-version.cmake
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-10-30 07:37:41 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-10-30 08:39:32 +0100
commitaa066bdd4622d4f6824fee864f6be6806813f04d (patch)
tree3df328b8b364cba2373a85827191b259bd78d546 /cmake/opentrack-version.cmake
parentd6a54431d178632a2bf466c9904f74abd143afe6 (diff)
move to subdirectory-based build system
Closes #224
Diffstat (limited to 'cmake/opentrack-version.cmake')
-rw-r--r--cmake/opentrack-version.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake
new file mode 100644
index 00000000..64072e1c
--- /dev/null
+++ b/cmake/opentrack-version.cmake
@@ -0,0 +1,33 @@
+include(GetGitRevisionDescription)
+
+find_package(Git QUIET)
+if(GIT_FOUND)
+ git_describe(OPENTRACK_COMMIT --tags --always --dirty)
+ git_describe(OPENTRACK_TAG_EXACT --tag --exact)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/opentrack-version.h "#define OPENTRACK_VERSION \"${OPENTRACK_COMMIT}\"")
+
+add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.cc)
+opentrack_compat(opentrack-version)
+
+set(version-string "
+#include \"opentrack-compat/export.hpp\"
+
+#ifdef __cplusplus
+extern \"C\"
+#endif
+OPENTRACK_EXPORT
+const char* opentrack_version;
+
+const char* opentrack_version = \"${OPENTRACK_COMMIT}\";
+")
+
+set(crapola-ver)
+if(EXISTS ${CMAKE_BINARY_DIR}/version.cc)
+ file(READ ${CMAKE_BINARY_DIR}/version.cc crapola-ver)
+endif()
+
+if(NOT (crapola-ver STREQUAL version-string))
+ file(WRITE ${CMAKE_BINARY_DIR}/version.cc "${version-string}")
+endif()