summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAmir Bawab <amirbawab@gmail.com>2019-10-09 23:12:28 -0400
committerSam Clegg <sbc@chromium.org>2019-10-09 20:12:28 -0700
commit8d6f79d2b11b5ab54a6965d072afccd66629947d (patch)
treefbdb7188a2c765c7f9f2b59d970481638a6f8e17 /CMakeLists.txt
parent6d39c5876efbcae17df6c6d45d371b9194fb0b28 (diff)
downloadwabt-8d6f79d2b11b5ab54a6965d072afccd66629947d.tar.gz
wabt-8d6f79d2b11b5ab54a6965d072afccd66629947d.tar.bz2
wabt-8d6f79d2b11b5ab54a6965d072afccd66629947d.zip
Add `--version` to wabt tools (#1175)
Closes: #1106 Ported versioning system from [Binaryen CMakeLists.txt](https://github.com/WebAssembly/binaryen/blob/dc31b460fef47dfb3415b4ae6276fff4919a03e2/CMakeLists.txt#L10-L23) ``` bin/wasm2c --version 1.0.11-44-g71f883ad ``` Applied to (all) tools in `src/tools/`.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2de12a79..b47aa470 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,22 @@ include(CheckTypeSize)
check_type_size(ssize_t SSIZE_T)
check_type_size(size_t SIZEOF_SIZE_T)
+FIND_PACKAGE(Git QUIET REQUIRED)
+EXECUTE_PROCESS(COMMAND
+ "${GIT_EXECUTABLE}" --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git describe --tags
+ RESULT_VARIABLE
+ GIT_HASH_RESULT
+ OUTPUT_VARIABLE
+ GIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+IF(${GIT_HASH_RESULT})
+ MESSAGE(WARNING "Error running git describe to determine version")
+ SET(WABT_VERSION_INFO "(unable to determine version)")
+ELSE()
+ SET(WABT_VERSION_INFO "${GIT_HASH}")
+ENDIF()
+
configure_file(
${WABT_SOURCE_DIR}/src/config.h.in
${WABT_BINARY_DIR}/config.h