From 771760b5384aec26333ddfd082ddeb1159c89ea3 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 10 Jun 2011 09:59:27 +0000 Subject: [PATCH] Add the piece of CMake code to detect the URL of the current SVN branch (Still to-do for Git...) --- CMakeLists.txt | 17 +++++++++++++++-- Installation/CMakeLists.txt | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b768c31f2b..e879f1fe982 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,22 @@ if ( ${CGAL_SCM_NAME} STREQUAL "svn" ) find_program(SVN_EXECUTABLE svn DOC "subversion command line client") - # TODO detect name - set ( CGAL_SCM_BRANCH_NAME "n/a" ) + function(Subversion_GET_URL dir variable) + # use svnversion + execute_process(COMMAND "${SVN_EXECUTABLE}" info --xml "${dir}" + OUTPUT_VARIABLE ${variable} + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE ".*([^<]+).*" "\\1" ${variable} "${${variable}}") + if(NOT variable) + message("Warning: can not get the Subversion URL of directory ${dir}") + endif() + set(${variable} ${${variable}} PARENT_SCOPE) + endfunction(Subversion_GET_URL) + Subversion_GET_URL("${CGAL_INSTALLATION_PACKAGE_DIR}" CGAL_INSTALLATION_SVN_URL) + string(REGEX REPLACE "(.*)/Installation" "\\1" CGAL_TMP_SVN_BRANCH_NAME "${CGAL_INSTALLATION_SVN_URL}") + + set ( CGAL_SCM_BRANCH_NAME "${CGAL_TMP_SVN_BRANCH_NAME}" ) endif() if ( ${CGAL_SCM_NAME} STREQUAL "git" ) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 6064f6009ca..987ab7da0e4 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -134,6 +134,9 @@ if ( CGAL_BRANCH_BUILD ) OUTPUT_VARIABLE ${variable} OUTPUT_STRIP_TRAILING_WHITESPACE) string(REGEX REPLACE "^(.*\n)? revision=\"([^\n]+)\".*url.*" "\\2" ${variable} "${${variable}}") + if(NOT variable) + message("Warning: can not get the Subversion revision of directory ${dir}") + endif() set(${variable} ${${variable}} PARENT_SCOPE) endfunction(Subversion_GET_REVISION)