diff options
author | click <click@gonnamakeyou.com> | 2013-02-11 01:56:25 +0100 |
---|---|---|
committer | click <click@gonnamakeyou.com> | 2013-02-11 01:56:25 +0100 |
commit | 2cf8cdaa800b032eba484811f65cf619af07e80f (patch) | |
tree | 8288482db64c2b49a0efab7a74a5af19029b4bde | |
parent | 1b4a6109764d74d6b440bcd796c2b375aa660096 (diff) |
Buildsystem/CMake: Drop a FATAL_ERROR-message if the git binary is not found or outdated.
Allow for it to be pointed to through the ADVANCED settings in the CMake GUI if the above is true.
-rw-r--r-- | cmake/genrev.cmake | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/cmake/genrev.cmake b/cmake/genrev.cmake index c7a188d1993..0df1770e142 100644 --- a/cmake/genrev.cmake +++ b/cmake/genrev.cmake @@ -12,17 +12,23 @@ include(${CMAKE_SOURCE_DIR}/cmake/macros/EnsureVersion.cmake) set(_REQUIRED_GIT_VERSION "1.7") -find_program(_GIT_EXEC +find_program(GIT_EXEC NAMES git git.cmd HINTS ENV PATH - DOC "git installation path" + DOC "Full path to git commandline client" ) +MARK_AS_ADVANCED(GIT_EXEC) -if(_GIT_EXEC) +if(NOT GIT_EXEC) + message(FATAL_ERROR " + Git was NOT FOUND on your system - did you forget to install a recent version, or setting the path to it? + Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION} + ") +else() execute_process( - COMMAND "${_GIT_EXEC}" --version + COMMAND "${GIT_EXEC}" --version WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE _GIT_VERSION ERROR_QUIET @@ -30,27 +36,31 @@ if(_GIT_EXEC) # make sure we're using minimum the required version of git, so the "dirty-testing" will work properly ensure_version( "${_REQUIRED_GIT_VERSION}" "${_GIT_VERSION}" _GIT_VERSION_OK) + + # throw an error if we don't have a recent enough version of git... + if(NOT _GIT_VERSION_OK) + message(FATAL_ERROR " + Git was found but is OUTDATED - did you forget to install a recent version, or setting the path to it? + Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION} + ") + endif() endif() if(_GIT_VERSION_OK) execute_process( - COMMAND "${_GIT_EXEC}" describe --match init --dirty=+ --abbrev=12 + COMMAND "${GIT_EXEC}" describe --match init --dirty=+ --abbrev=12 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE rev_info OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) execute_process( - COMMAND "${_GIT_EXEC}" show -s --format=%ci + COMMAND "${GIT_EXEC}" show -s --format=%ci WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE rev_date OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) -else() - message("") - message(STATUS "WARNING - Missing or outdated git - did you forget to install a recent version?") - message(STATUS "WARNING - Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION}") endif() # Last minute check - ensure that we have a proper revision |