Commit cdc11dc7 authored by Ghislain MARY's avatar Ghislain MARY

Add protection to have tag and version aligned also with CMake.

parent 207d60d2
......@@ -24,11 +24,10 @@ cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(flexisip C CXX)
set(FLEXISIP_MAJOR_VERSION "0")
set(FLEXISIP_MINOR_VERSION "8")
set(FLEXISIP_MICRO_VERSION "0")
set(FLEXISIP_MAJOR_VERSION "1")
set(FLEXISIP_MINOR_VERSION "0")
set(FLEXISIP_MICRO_VERSION "8")
set(FLEXISIP_VERSION "${FLEXISIP_MAJOR_VERSION}.${FLEXISIP_MINOR_VERSION}.${FLEXISIP_MICRO_VERSION}")
set(FLEXISIP_SO_VERSION "6")
include(CMakePushCheckState)
include(CMakeDependentOption)
......
......@@ -82,7 +82,7 @@ set(FLEXISIP_SOURCES
find_package(Git)
add_custom_target(flexisip-git-version
COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DWORK_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/gitversion.cmake
COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DFLEXISIP_VERSION=${FLEXISIP_VERSION} -DWORK_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/gitversion.cmake
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/flexisip_gitversion.h"
)
......
......@@ -20,15 +20,35 @@
#
############################################################################
if(GIT_EXECUTABLE)
macro(execute_git GIT_OUTPUT_VARIABLE)
set(_subcommand_list "${ARGN}")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --always
COMMAND ${GIT_EXECUTABLE} ${_subcommand_list}
WORKING_DIRECTORY ${WORK_DIR}
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_VARIABLE ${GIT_OUTPUT_VARIABLE}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endmacro()
if(GIT_EXECUTABLE)
execute_git(GIT_DESCRIBE describe)
execute_git(GIT_REVISION rev-parse HEAD)
execute_git(GIT_TAG describe --abbrev=0)
else()
set(GIT_REVISION "unknown")
set(GIT_DESCRIBE)
set(GIT_REVISION)
set(GIT_TAG)
endif()
configure_file("${WORK_DIR}/gitversion.h.in" "${OUTPUT_DIR}/flexisip_gitversion.h" @ONLY)
if(GIT_DESCRIBE)
if(NOT GIT_TAG STREQUAL FLEXISIP_VERSION)
message(FATAL_ERROR "FLEXISIP_VERSION and git tag differ. Please put them identical.")
endif()
set(GIT_VERSION "${GIT_DESCRIBE}")
configure_file("${WORK_DIR}/gitversion.h.in" "${OUTPUT_DIR}/flexisip_gitversion.h" @ONLY)
elseif(GIT_REVISION)
set(GIT_VERSION "${FLEXISIP_VERSION}_${GIT_REVISION}")
configure_file("${WORK_DIR}/gitversion.h.in" "${OUTPUT_DIR}/flexisip_gitversion.h" @ONLY)
elseif(NOT EXISTS "${OUTPUT_DIR}/flexisip_gitversion.h")
file(WRITE "${OUTPUT_DIR}/flexisip_gitversion.h" "")
endif()
......@@ -17,4 +17,4 @@
*/
#define FLEXISIP_GIT_VERSION "@GIT_REVISION@"
\ No newline at end of file
#define FLEXISIP_GIT_VERSION "@GIT_VERSION@"
\ 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