diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-10-15 14:40:18 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-10-15 14:45:42 -0400 |
commit | 92b17e174f19a0a851a595d63663cda4cb8ac336 (patch) | |
tree | 15b7b03c5798b3889c923c29c2fe85bed8ec4c60 | |
parent | 7e57d326f465ec541a9d0c14a286bc603bd543d7 (diff) | |
download | rneovim-92b17e174f19a0a851a595d63663cda4cb8ac336.tar.gz rneovim-92b17e174f19a0a851a595d63663cda4cb8ac336.tar.bz2 rneovim-92b17e174f19a0a851a595d63663cda4cb8ac336.zip |
cmake: handle missing git or .git/
GetGitRevisionDescription.cmake: we don't need fine-grained failure
modes, we only need "yes" or "no".
fix #1292
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | cmake/GetGitRevisionDescription.cmake | 35 |
2 files changed, 18 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fab8d52e5..87dd600606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,9 @@ list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR}) # Version tokens include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT) +if (NOT NVIM_VERSION_COMMIT) + set(NVIM_VERSION_COMMIT "?") +endif() set(NVIM_VERSION_MAJOR 0) set(NVIM_VERSION_MINOR 0) set(NVIM_VERSION_PATCH 0) @@ -22,7 +25,9 @@ set(NVIM_VERSION_PRERELEASE "-alpha") # TODO(justinmk): UTC time would be nice here #1071 git_timestamp(GIT_TIMESTAMP) # TODO(justinmk): do not set this for "release" builds #1071 -set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}") +if (GIT_TIMESTAMP) + set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}") +endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake index 047b719f2a..dec748d094 100644 --- a/cmake/GetGitRevisionDescription.cmake +++ b/cmake/GetGitRevisionDescription.cmake @@ -70,8 +70,6 @@ endfunction() function(get_git_head_revision _refspecvar _hashvar) get_git_dir(GIT_DIR) if(NOT GIT_DIR) - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) return() endif() @@ -96,6 +94,11 @@ function(get_git_head_revision _refspecvar _hashvar) endfunction() function(git_describe _var) + get_git_dir(GIT_DIR) + if(NOT GIT_DIR) + return() + endif() + if(NOT GIT_FOUND) find_package(Git QUIET) endif() @@ -103,27 +106,13 @@ function(git_describe _var) set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) return() endif() - get_git_dir(GIT_DIR) - if(NOT GIT_DIR) - set(${_var} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() + get_git_head_revision(refspec hash) if(NOT hash) set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) return() endif() - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - #message(STATUS "Arguments to execute_process: ${ARGN}") - execute_process(COMMAND "${GIT_EXECUTABLE}" describe @@ -145,18 +134,18 @@ function(git_describe _var) endfunction() function(git_timestamp _var) + get_git_dir(GIT_DIR) + if(NOT GIT_DIR) + return() + endif() + if(NOT GIT_FOUND) find_package(Git QUIET) endif() if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - get_git_dir(GIT_DIR) - if(NOT GIT_DIR) - set(${_var} "GITDIR-NOTFOUND" PARENT_SCOPE) return() endif() + get_git_head_revision(refspec hash) if(NOT hash) set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) |