summaryrefslogtreecommitdiffstats
path: root/cmake/generate_version.cmake
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-02 17:42:30 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-02 17:47:20 +0100
commit38b7d50694b4a9929cc0d5bca884a52d5aeaa8a4 (patch)
tree8d5c690296423b9261a864c1b8cfde06b85d9d9a /cmake/generate_version.cmake
parentcd47acaf3cc874f8d26acca56fa6cef6110d946d (diff)
downloadfastd-38b7d50694b4a9929cc0d5bca884a52d5aeaa8a4.tar
fastd-38b7d50694b4a9929cc0d5bca884a52d5aeaa8a4.zip
Separate cmake files
Diffstat (limited to 'cmake/generate_version.cmake')
-rw-r--r--cmake/generate_version.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/generate_version.cmake b/cmake/generate_version.cmake
new file mode 100644
index 0000000..bf69bac
--- /dev/null
+++ b/cmake/generate_version.cmake
@@ -0,0 +1,12 @@
+set(VERSION_FILE "${FASTD_BINARY_DIR}/src/fastd_version.h")
+
+add_custom_target(
+ version
+ COMMAND echo "#ifndef _FASTD_FASTD_VERSION_H_" > "${VERSION_FILE}.new"
+ COMMAND echo "#define _FASTD_FASTD_VERSION_H_" >> "${VERSION_FILE}.new"
+ COMMAND sh -c "echo \"#define FASTD_VERSION \\\"$(git --git-dir=./.git describe --dirty 2>/dev/null || echo ${FASTD_VERSION})\\\"\"" >> "${VERSION_FILE}.new"
+ COMMAND echo "#endif /* _FASTD_FASTD_VERSION_H_ */" >> "${VERSION_FILE}.new"
+ COMMAND cmp -s "${VERSION_FILE}" "${VERSION_FILE}.new" && rm "${VERSION_FILE}.new" || mv "${VERSION_FILE}.new" "${VERSION_FILE}"
+ WORKING_DIRECTORY "${FASTD_SOURCE_DIR}"
+ VERBATIM
+)