Commit f2ca47fa authored by Jean-Loup HABERBUSCH's avatar Jean-Loup HABERBUSCH
Browse files

UPDATED Cmake file for configuring using Git. SVN is not supported anymore

NEW CMake macro get_git_info to find useful information to configure camitk
parent ef559095
......@@ -13,9 +13,9 @@ enable_testing()
# Specific to SDK: control the version (major, minor, default patch and )
set(CAMITK_PROJECT_NAME "CamiTK")
set(CAMITK_VERSION_MAJOR "3")
set(CAMITK_VERSION_MINOR "6")
set(CAMITK_VER_NICKNAME "cyan") # blue, sapphire, azure, *indigo*, iris, Teal, cyan, turquoise, denim, celeste, zaffre, glaucous, ultramarine, cerulean
set(CAMITK_VERSION_MAJOR "4")
set(CAMITK_VERSION_MINOR "0")
set(CAMITK_VER_NICKNAME "red") # Red Amaranth American rose Auburn Burgundy Cardinal Carmine Carnelian Cerise Coquelicot
set(CAMITK_VERSION_PATCH "0") # patch version for packaging, change when appropriate
string(TOLOWER "${CAMITK_PROJECT_NAME}-${CAMITK_VERSION_MAJOR}.${CAMITK_VERSION_MINOR}" CAMITK_SHORT_VERSION_STRING)
......
......@@ -23,25 +23,24 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/CamiTKVersion.h.in ${C
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/CamiTKVersion.h)
set(CAMITK_SOURCE_PACKAGE_VERSION "0")
# If this file does not exist => this is a svn checkouted source tree.
find_package(Subversion QUIET)
if(Subversion_FOUND)
find_package(Git QUIET)
if(GIT_FOUND)
set(CAMITK_GIT_FOUND "1")
# Call a macro Git_WC_INFO which is define in
# GetGitInfo.cmake to get all information from
# the svn command itself
include(cmake/modules/macros/GetGitInfo.cmake)
get_git_info(${CMAKE_CURRENT_SOURCE_DIR})
set(CAMITK_VERSION_GIT ".${CAMITK_GIT_COMMIT_COUNT}")
set(CAMITK_SVN_SUBVERSION_FOUND "1")
# get all information from the svn command itself
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} CAMITK_SVN)
set(CAMITK_VERSION_SVN ".${CAMITK_SVN_WC_REVISION}")
string(REGEX REPLACE "^([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+).*" "\\1-\\2-\\3 \\4:\\5:\\6" CAMITK_SVN_DATE "${CAMITK_SVN_WC_LAST_CHANGED_DATE}")
else()
set(CAMITK_SVN_SUBVERSION_FOUND "0")
# svn command is not accessible, just set the string to something
set(CAMITK_VERSION_SVN ".svn")
endif()
else()
set(CAMITK_SVN_SUBVERSION_FOUND "0")
set(CAMITK_SOURCE_PACKAGE_VERSION "1")
endif()
# specific version string using the svn revision
set(CAMITK_VERSION_STRING "${CAMITK_VERSION_STRING}${CAMITK_VERSION_SVN}")
# specific version string using the git revision
set(CAMITK_VERSION_STRING "${CAMITK_VERSION_STRING}${CAMITK_VERSION_GIT}")
# prepare the CamiTKConfig.cmake for installation (first delete it to force regeneration)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_BINARY_DIR}/share/${CAMITK_SHORT_VERSION_STRING}/cmake/CamiTKConfig.cmake)
......@@ -52,4 +51,4 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/CamiTKVersion.h.in ${C
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "Welcome to ${CAMITK_VERSION_STRING} SDK compilation")
message(STATUS "Welcome to ${CAMITK_VERSION_STRING} SDK compilation")
\ No newline at end of file
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
std::cout << "Compiled using package source." << std::endl;
else {
std::cout << "Compiled using svn";
if (hasMoreSvnInformation()) {
if (hasMoreSvnInformation()) { //Check if CAMITK_SVN_SUBVERSION_FOUND can be set to "1" otherwise we never get into this 'if'
std::cout << " Rev: " << svnRevision() << ", Date: " << svnDate() << std::endl;
}
std::cout << "." << std::endl;
......
#!
#! @ingroup group_sdk_cmake
#!
#! macro get_git_info get the last value of commit count.
#! Set CAMITK_GIT_COMMIT_COUNT variable with the last number of commits
#!
#! Usage:
#! \code
#! get_git_info(dir)
#! \endcode
#!
#! \inparam dir (required) input directory path
#!
macro(get_git_info dir)
# the subversion commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated, Alex
# set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
# set(ENV{LC_ALL} C)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE CAMITK_GIT_COMMIT_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT CAMITK_GIT_COMMIT_COUNT)
message(WARNING "Unable to find the commit number using git : ${GIT_EXECUTABLE}")
set(CAMITK_GIT_COMMIT_COUNT "unknown")
endif()
endmacro()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment