Skip to content

Commit

Permalink
Merge pull request #436 from marvelous/master
Browse files Browse the repository at this point in the history
detect git repo even when in submodule
  • Loading branch information
stephanemagnenat committed Oct 22, 2015
2 parents 8f234c4 + 92c51f5 commit cf8b76d
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions ParseVersion.cmake
Expand Up @@ -52,27 +52,23 @@ endif (NOT GIT_FOUND)

if (GIT_FOUND)
message("-- Git executable found")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short --verify HEAD
OUTPUT_VARIABLE GIT_REV
ERROR_VARIABLE git_rev_error
RESULT_VARIABLE git_rev_result
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${git_rev_result} EQUAL 0)
set(HAS_GIT_REP 1)
endif(${git_rev_result} EQUAL 0)
else (GIT_FOUND)
message("-- Git executable NOT found")
endif (GIT_FOUND)

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
set(HAS_GIT_REP 1)
endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")

# react accordingly
if (GIT_FOUND AND HAS_GIT_REP)
message("-- Git repository found")
set(HAS_DYN_VERSION)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short --verify HEAD
OUTPUT_VARIABLE GIT_REV
ERROR_VARIABLE git_rev_error
RESULT_VARIABLE git_rev_result
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${git_rev_result} EQUAL 0)
message(SEND_ERROR "Command \"${GIT_EXECUTABLE} rev-parse --short --verify HEAD\" failed with output:\n${git_rev_error}")
endif(NOT ${git_rev_result} EQUAL 0)
# write a file with the GIT_REV define
file(WRITE ${CMAKE_BINARY_DIR}/version.h.txt "#define ASEBA_BUILD_VERSION \"git-${GIT_REV}\"\n")
# write NSIS version file (for Windows build)
Expand Down

0 comments on commit cf8b76d

Please sign in to comment.