aboutsummaryrefslogtreecommitdiff
path: root/version.cmake
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2014-11-25 21:48:54 +0200
committerRiccardo Spagni <ric@spagni.net>2014-11-25 21:49:00 +0200
commitab7c6c07e71c025a978948760159f823cc48fe37 (patch)
tree076a6ae171a256e68474d3617abbd3715fa579fc /version.cmake
parentMerge pull request #184 (diff)
parentcmake: work around a bug with implicit link directories (diff)
downloadmonero-ab7c6c07e71c025a978948760159f823cc48fe37.tar.xz
Merge pull request #180
ce71c01 cmake: work around a bug with implicit link directories (Ben Boeckel) de4fc40 mingw: copy required libraries to the build tree (Ben Boeckel) ec54e2f cmake: place binaries together in the build tree (Ben Boeckel) 18c56ab msys: don't use LTO (Ben Boeckel) 5680c9c msys: factor out -Werror on msys (Ben Boeckel) 4751542 msys: look in msys' directory for files (Ben Boeckel) d855fe4 miniupnpc: bump the _POSIX_C_SOURCE feature macro (Ben Boeckel) c696492 unbound: fix getaddrinfo detection for 32-bit windows (Ben Boeckel) e377687 cmake: Windows and static builds need this (Ben Boeckel) 01895dd cmake: fix up link lines (Ben Boeckel) 4b6515c unbound: fix type checking (Ben Boeckel) d43a20f unbound: plumb the libdir up (Ben Boeckel) 7d708e4 cmake: support 2.8.7 (Ben Boeckel) 464c280 cmake: fix up miniupnpc's define (Ben Boeckel) 9689df9 cmake: clean up EXTRA_LIBRARIES (Ben Boeckel) 3b7bdcb cmake: set the project name (Ben Boeckel) 0f0efc4 cmake: prepend to CMAKE_MODULE_PATH (Ben Boeckel) 031e3da cmake: remove scream-make (all-caps functions) (Ben Boeckel) abbd5c0 unbound: import cmake build system (Ben Boeckel) e59b5b7 miniupnpc: clean up build system (Ben Boeckel) 475fe20 cmake: minor cleanups (indentation and typos) (Ben Boeckel) 799e8b2 cmake: use option() for STATIC (Ben Boeckel) c24d22b cmake: clean up if auto-dereferencing (Ben Boeckel) 9ed415a build: inform the build of what generates version.h (Ben Boeckel) eba180a cmake: support git info in released tarballs (Ben Boeckel) eeffac6 cmake: fix up BOOST_IGNORE_SYSTEM_PATHS (Ben Boeckel) a43f1a8 cmake: remove configuration variables (Ben Boeckel) a87ce09 cmake: factor out error messages (Ben Boeckel) 9aa48b6 miniupnpc: clear out else/endfoo command arguments (Ben Boeckel) 8a86ac8 daemon_tests: update cmake code (Ben Boeckel) fa3ff75 gtest: support an external gtest (Ben Boeckel) 7bfcffa cmake: put each test executable in its own directory (Ben Boeckel) f53f047 cmake: handle private vs. public headers (Ben Boeckel) 55ca7d3 cmake: refactor common code with libraries (Ben Boeckel) c773f46 cmake: refactor common code with executables (Ben Boeckel) 89cff7b cmake: put each library into its own directory (Ben Boeckel)
Diffstat (limited to 'version.cmake')
-rw-r--r--version.cmake33
1 files changed, 33 insertions, 0 deletions
diff --git a/version.cmake b/version.cmake
new file mode 100644
index 000000000..80f1c40b8
--- /dev/null
+++ b/version.cmake
@@ -0,0 +1,33 @@
+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}")
+ set(extra_output)
+ if (CMAKE_GENERATOR MATCHES "Ninja")
+ # Ninja will not rerun the command every time if the file doesn't change,
+ # so inject this bogus output so that it always runs.
+ set(extra_output "${CMAKE_SOURCE_DIR}/.force-git-version-check")
+ endif ()
+ add_custom_command(
+ OUTPUT "${CMAKE_BINARY_DIR}/version/version.h"
+ ${extra_output}
+ COMMAND "${CMAKE_COMMAND}"
+ "-D" "GIT=${GIT_EXECUTABLE}"
+ "-D" "TO=${CMAKE_BINARY_DIR}/version/version.h"
+ "-P" "src/version.cmake"
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+ add_custom_target(version ALL
+ DEPENDS "${CMAKE_BINARY_DIR}/version/version.h")
+else()
+ message(STATUS "WARNING: Git was not found!")
+ write_static_version_header("unknown")
+endif ()