mirror of https://github.com/CGAL/cgal
fix if git dir is already given dir
This commit is contained in:
parent
7937e731d8
commit
ddd4ca95da
|
|
@ -6,26 +6,32 @@ if( NOT CGAL_SCM_FILE_INCLUDED )
|
|||
|
||||
set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
#message ("-----GPD1: ${GIT_PARENT_DIR}")
|
||||
#message ("-----PPD1: ${GIT_PREVIOUS_PARENT}")
|
||||
if( "${GIT_PARENT_DIR}" STREQUAL "${GIT_PREVIOUS_PARENT}" )
|
||||
# We have reached the root directory, we are not in git
|
||||
set(_refspecvar "GITDIR-NOTFOUND")
|
||||
set(_hashvar "GITDIR-NOTFOUND")
|
||||
set ( CGAL_SCM_NAME "" )
|
||||
break()
|
||||
else()
|
||||
set( GIT_DIR "${GIT_PARENT_DIR}/.git" )
|
||||
set( CGAL_SCM_NAME "git" )
|
||||
endif()
|
||||
endwhile()
|
||||
#message ("-----GD: ${GIT_DIR}")
|
||||
if (EXISTS "${GIT_DIR}")
|
||||
set( CGAL_SCM_NAME "git" )
|
||||
else()
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
#message ("-----GPD1: ${GIT_PARENT_DIR}")
|
||||
#message ("-----PPD1: ${GIT_PREVIOUS_PARENT}")
|
||||
if( "${GIT_PARENT_DIR}" STREQUAL "${GIT_PREVIOUS_PARENT}" )
|
||||
# We have reached the root directory, we are not in git
|
||||
set(_refspecvar "GITDIR-NOTFOUND")
|
||||
set(_hashvar "GITDIR-NOTFOUND")
|
||||
set ( CGAL_SCM_NAME "" )
|
||||
break()
|
||||
else()
|
||||
set( GIT_DIR "${GIT_PARENT_DIR}/.git" )
|
||||
set( CGAL_SCM_NAME "git" )
|
||||
endif()
|
||||
endwhile()
|
||||
endif()
|
||||
|
||||
#message ("====GPD1: ${GIT_PARENT_DIR}")
|
||||
|
||||
if ( "${CGAL_SCM_NAME}" STREQUAL "git" )
|
||||
#message ("====GPD: ${GIT_PARENT_DIR}")
|
||||
#message ("====GPD2: ${GIT_PARENT_DIR}")
|
||||
|
||||
find_program(GIT_EXECUTABLE git DOC "git command line client")
|
||||
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --git-dir=${GIT_PARENT_DIR}/.git symbolic-ref HEAD
|
||||
|
|
|
|||
Loading…
Reference in New Issue