diff --git a/projectheader.cmake b/projectheader.cmake index 83df340..750268c 100644 --- a/projectheader.cmake +++ b/projectheader.cmake @@ -3,12 +3,37 @@ # @param CURRENT_PROJECT_BINARY_DIR [optional] Override for the default project binary dir (PROJECT_BINARY_DIR for executables, CMAKE_BINARY_DIR for libraries). macro ( project_header CURRENT_PROJECT_NAME ) +# Determine the version and fill the following variables : +# SOVERSION : The tag from the git-repository. Not necessarily a number-only string. +find_package(Git QUIET) + +if(GIT_FOUND) + if( EXISTS "${PROJECT_SOURCE_DIR}/.git") + execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE CURRENT_PROJECT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + message( STATUS "================================================================" ) + message( STATUS "Found the following tag : ${CURRENT_PROJECT_VERSION}") + message( STATUS "================================================================" ) + else() + message( STATUS ".git directory does not exists..") + message( STATUS "Project directory : ${PROJECT_SOURCE_DIR}") + endif() +else() + message( STATUS "git-command not found....") + message( FATAL "Unable to determine the version of the software.") +endif() + message( STATUS "" ) message( STATUS "================================================================" ) message( STATUS "Creating Makefile of ${CURRENT_PROJECT_NAME}" ) message( STATUS "================================================================" ) message( STATUS "CURRENT_PROJECT_VERSION: ${CURRENT_PROJECT_VERSION}" ) +set(SOVERSION "${CURRENT_PROJECT_VERSION}") +set(VERSION "${CURRENT_PROJECT_VERSION}") + project(${CURRENT_PROJECT_NAME} VERSION ${CURRENT_PROJECT_VERSION}) set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES 1)