summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2020-01-08 12:17:48 -0800
committerGitHub <noreply@github.com>2020-01-08 12:17:48 -0800
commit8d4db9fb86c3b80df3eaa0d8e5eb379d081c8399 (patch)
tree44e4e0d3e6673b5971899f1277643df7862913b1
parent132daae1e9154782bb1afa5df80dfe7ea35f0369 (diff)
downloadbinaryen-8d4db9fb86c3b80df3eaa0d8e5eb379d081c8399.tar.gz
binaryen-8d4db9fb86c3b80df3eaa0d8e5eb379d081c8399.tar.bz2
binaryen-8d4db9fb86c3b80df3eaa0d8e5eb379d081c8399.zip
Remove git dependency (#2578)
Only use git to set version number if .git directory is present. This means that for release archives the VERSION string will be used as-is. Fixes #2563
-rw-r--r--CMakeLists.txt32
-rw-r--r--config.h.in2
-rw-r--r--src/support/command-line.cpp2
3 files changed, 20 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b338943ff..afd700c41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
-project(binaryen C CXX)
cmake_minimum_required(VERSION 3.1.3)
+project(binaryen LANGUAGES C CXX VERSION 90)
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE)
@@ -11,20 +11,24 @@ endif()
# more useful error reports from users.
option(BYN_ENABLE_ASSERTIONS "Enable assertions" ON)
-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(BINARYEN_VERSION_INFO "(unable to determine version)")
-else()
- set(BINARYEN_VERSION_INFO "${GIT_HASH}")
+# For git users, attempt to generate a more useful version string
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+ 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(CMAKE_PROJECT_VERSION "(unable to determine version)")
+ else()
+ set(CMAKE_PROJECT_VERSION "${GIT_HASH}")
+ endif()
endif()
+
configure_file(config.h.in config.h)
# Support functionality.
diff --git a/config.h.in b/config.h.in
index 17f2018e2..21bd41343 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1 +1 @@
-#cmakedefine BINARYEN_VERSION_INFO "${BINARYEN_VERSION_INFO}"
+#cmakedefine CMAKE_PROJECT_VERSION "${CMAKE_PROJECT_VERSION}"
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index 0986a49ff..e6cd352bb 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -58,7 +58,7 @@ Options::Options(const std::string& command, const std::string& description)
"Output version information and exit",
Arguments::Zero,
[command](Options*, const std::string&) {
- std::cout << command << " " << BINARYEN_VERSION_INFO << "\n";
+ std::cout << command << " " << CMAKE_PROJECT_VERSION << "\n";
exit(0);
});
add("--help",