better handling if source of executable is not in a git repo

This commit is contained in:
Eric Berberich 2012-10-22 23:38:25 +00:00
parent fc6d74c399
commit fe43dd0171
2 changed files with 20 additions and 15 deletions

View File

@ -2,27 +2,30 @@
if( NOT CGAL_SCM_FILE_INCLUDED )
set(CGAL_SCM_FILE_INCLUDED 1 )
#message ("-----CSD: ${CMAKE_SOURCE_DIR}")
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)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
#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" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(_refspecvar "GITDIR-NOTFOUND")
set(_hashvar "GITDIR-NOTFOUND")
set ( CGAL_SCM_NAME "" )
break()
else()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
set( GIT_DIR "${GIT_PARENT_DIR}/.git" )
set( CGAL_SCM_NAME "git" )
endif()
endwhile()
endwhile()
if ( NOT "${_refspecvar}" STREQUAL "GITDIR-NOTFOUND" )
set ( CGAL_SCM_NAME "git" )
endif()
#message ("GPD: ${GIT_PARENT_DIR}")
if ( ${CGAL_SCM_NAME} STREQUAL "git" )
if ( "${CGAL_SCM_NAME}" STREQUAL "git" )
#message ("====GPD: ${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

View File

@ -20,13 +20,15 @@ if(NOT USE_CGAL_FILE_INCLUDED)
include(CGAL_TweakFindBoost)
set(CGAL_INSTALLED_SCM_BRANCH_NAME ${CGAL_SCM_BRANCH_NAME})
set(CGAL_SCM_BRANCH_NAME "")
if( NOT "${CGAL_INSTALLED_SCM_BRANCH_NAME}" STREQUAL "" )
include(CGAL_SCM)
message ( STATUS "Code taken from Git branch: ${CGAL_SCM_BRANCH_NAME}")
if ( NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "" AND
NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "${CGAL_INSTALLED_SCM_BRANCH_NAME}")
message (AUTHOR_WARNING "Branch '${CGAL_SCM_BRANCH_NAME}' does not match branch '${CGAL_INSTALLED_SCM_BRANCH_NAME}' from which CGAL has been installed. Please consider to rebuild CGAL from this branch.")
if ( NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "" )
message ( STATUS "Code taken from Git branch: ${CGAL_SCM_BRANCH_NAME}")
if ( NOT "${CGAL_SCM_BRANCH_NAME}" STREQUAL "${CGAL_INSTALLED_SCM_BRANCH_NAME}")
message (AUTHOR_WARNING "Branch '${CGAL_SCM_BRANCH_NAME}' does not match branch '${CGAL_INSTALLED_SCM_BRANCH_NAME}' from which CGAL has been installed. Please consider to rebuild CGAL from this branch.")
endif()
endif()
endif()