Skip to content
Snippets Groups Projects
Commit 0684b39e authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Improve version numbering management

- allow to define version numbers such as a.b.c(-suffix), where the optional
  suffix parameter may be for instance rc2, beta3 or so...

- deduce the suffix-less release number (a.b.c) since cmake does not support
  release number suffixes...

- improve git-tag matching mechanism. One now searches for the nearest tag that
  matches 'v[0-9]*' and checks if it corresponds to the current release
  number. This allows to define annotate tags that are not related to version
  tags. The only constrain is that such tags must not match 'v[0-9]*'
parent f108fa4b
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,17 @@ include(CheckNotInSources)
#----------------- Main configuration -----------------
#------------------------------------------------------
project (Pastis
VERSION 0.3.0)
# custom variable allowing to define version suffixes such as -rc*, -beta*, ...
set(PASTIS_VERSION "0.3.0")
# deduce PASTIS_SHORT_VERSION using regex
string(REGEX MATCH "^[0-9]+\.[0-9]+\.[0-9]+" PASTIS_SHORT_VERSION ${PASTIS_VERSION})
if("${PASTIS_SHORT_VERSION}" STREQUAL "")
message(FATAL_ERROR "Unable to compute short version from PASTIS_VERSION=${PASTIS_VERSION}")
endif()
# set project version as PASTIS_SHORT_VERSION
project (Pastis VERSION ${PASTIS_SHORT_VERSION})
#------------------------------------------------------
......@@ -24,23 +33,23 @@ set(PASTIS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# Add new build types
message("* Adding build types...")
SET(CMAKE_CXX_FLAGS_COVERAGE
set(CMAKE_CXX_FLAGS_COVERAGE
"-g -Wall -O0 --coverage"
CACHE STRING "Flags used by the C++ compiler during coverage builds."
FORCE )
SET(CMAKE_C_FLAGS_COVERAGE
set(CMAKE_C_FLAGS_COVERAGE
"-g -Wall -O0 --coverage"
CACHE STRING "Flags used by the C compiler during coverage builds."
FORCE )
SET(CMAKE_EXE_LINKER_FLAGS_COVERAGE
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE
"--coverage"
CACHE STRING "Flags used for linking binaries during coverage builds."
FORCE )
SET(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE
"--coverage"
CACHE STRING "Flags used by the shared libraries linker during coverage builds."
FORCE )
MARK_AS_ADVANCED(
mark_as_advanced(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
......
......@@ -6,7 +6,7 @@ find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe "--abbrev=0"
COMMAND "${GIT_EXECUTABLE}" describe "--abbrev=0" "--match=v[0-9]*"
WORKING_DIRECTORY "${PASTIS_SOURCE_DIR}"
OUTPUT_VARIABLE PASTIS_GIT_TAG
RESULT_VARIABLE FOUND_PASTIS_GIT_INFO
......@@ -45,12 +45,10 @@ else()
unset(HAS_PASTIS_GIT_INFO)
endif()
string(FIND "${PASTIS_GIT_TAG}" "${CMAKE_PASTIS_VERSION}" FOUND_VERSION_SUBSTR)
if(FOUND_PASTIS_GIT_INFO EQUAL 0)
if("${FOUND_VERSION_SUBSTR}" STREQUAL "-1")
if(NOT("${PASTIS_GIT_TAG}" STREQUAL "v${PASTIS_VERSION}"))
message("")
message ("###### CMake code version ${CMAKE_PASTIS_VERSION} and")
message ("###### CMake code version ${PASTIS_VERSION} and")
message ("###### git revision info ${PASTIS_GIT_TAG} do not match!")
message("")
endif()
......@@ -65,5 +63,3 @@ endif()
configure_file("${PASTIS_SOURCE_DIR}/src/utils/pastis_git_revision.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision"
@ONLY)
......@@ -51,7 +51,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision.hpp
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pastis_git_revision
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -DCMAKE_PASTIS_VERSION=${Pastis_VERSION} -DPASTIS_SOURCE_DIR=${PASTIS_SOURCE_DIR} -P ${PASTIS_SOURCE_DIR}/cmake/GetPastisGitRevision.cmake
COMMAND ${CMAKE_COMMAND} -DPASTIS_VERSION=${PASTIS_VERSION} -DPASTIS_SOURCE_DIR=${PASTIS_SOURCE_DIR} -P ${PASTIS_SOURCE_DIR}/cmake/GetPastisGitRevision.cmake
COMMENT "Check pastis git status"
VERBATIM
)
......
#ifndef PASTIS_VERSION_HPP
#define PASTIS_VERSION_HPP
#define PASTIS_VERSION "@Pastis_VERSION@"
#define PASTIS_VERSION "@PASTIS_VERSION@"
#endif // PASTIS_VERSION_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment