aboutsummaryrefslogtreecommitdiff
path: root/version.cmake
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-10-21 13:52:24 -0400
committerBen Boeckel <ben.boeckel@kitware.com>2014-10-23 16:42:34 -0400
commiteba180a1c786c4a86ead7e46f6e19febef4dd940 (patch)
treed02cef7ce4a390acc2b2854622563d881aedb991 /version.cmake
parentcmake: fix up BOOST_IGNORE_SYSTEM_PATHS (diff)
downloadmonero-eba180a1c786c4a86ead7e46f6e19febef4dd940.tar.xz
cmake: support git info in released tarballs
Diffstat (limited to '')
-rw-r--r--version.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/version.cmake b/version.cmake
new file mode 100644
index 000000000..4dd6db6d4
--- /dev/null
+++ b/version.cmake
@@ -0,0 +1,23 @@
+function (write_static_version_header hash)
+ set(VERSIONTAG "${hash}")
+ configure_file("src/version.h.in" "version/version.h")
+ add_custom_target(version ALL)
+endfunction ()
+
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
+find_package(Git QUIET)
+if ("$Format:$" STREQUAL "")
+ # We're in a tarball; use hard-coded variables.
+ write_static_version_header("release")
+elseif (GIT_FOUND OR Git_FOUND)
+ message(STATUS "Found Git: ${GIT_EXECUTABLE}")
+ add_custom_target(version ALL
+ COMMAND "${CMAKE_COMMAND}"
+ "-D" "GIT=${GIT_EXECUTABLE}"
+ "-D" "TO=${CMAKE_BINARY_DIR}/version/version.h"
+ "-P" "src/version.cmake"
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+else()
+ message(STATUS "WARNING: Git was not found!")
+ write_static_version_header("unknown")
+endif ()