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_PARENT_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
#message ("-----GD: ${GIT_DIR}")
|
||||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
if (EXISTS "${GIT_DIR}")
|
||||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
set( CGAL_SCM_NAME "git" )
|
||||||
#message ("-----GPD1: ${GIT_PARENT_DIR}")
|
else()
|
||||||
#message ("-----PPD1: ${GIT_PREVIOUS_PARENT}")
|
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||||
if( "${GIT_PARENT_DIR}" STREQUAL "${GIT_PREVIOUS_PARENT}" )
|
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||||
# We have reached the root directory, we are not in git
|
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||||
set(_refspecvar "GITDIR-NOTFOUND")
|
#message ("-----GPD1: ${GIT_PARENT_DIR}")
|
||||||
set(_hashvar "GITDIR-NOTFOUND")
|
#message ("-----PPD1: ${GIT_PREVIOUS_PARENT}")
|
||||||
set ( CGAL_SCM_NAME "" )
|
if( "${GIT_PARENT_DIR}" STREQUAL "${GIT_PREVIOUS_PARENT}" )
|
||||||
break()
|
# We have reached the root directory, we are not in git
|
||||||
else()
|
set(_refspecvar "GITDIR-NOTFOUND")
|
||||||
set( GIT_DIR "${GIT_PARENT_DIR}/.git" )
|
set(_hashvar "GITDIR-NOTFOUND")
|
||||||
set( CGAL_SCM_NAME "git" )
|
set ( CGAL_SCM_NAME "" )
|
||||||
endif()
|
break()
|
||||||
endwhile()
|
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" )
|
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")
|
find_program(GIT_EXECUTABLE git DOC "git command line client")
|
||||||
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --git-dir=${GIT_PARENT_DIR}/.git symbolic-ref HEAD
|
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --git-dir=${GIT_PARENT_DIR}/.git symbolic-ref HEAD
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue