~s-cecilio/lomse/master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#-------------------------------------------------------------------------------------
# This is part of CMake configuration file for building makefiles and installfiles
# for the Lomse library
#-------------------------------------------------------------------------------------
# This module creates the include file "lomse_version.h"
#
#-------------------------------------------------------------------------------------

set( LOMSE_VERSION_MAJOR 0 )
set( LOMSE_VERSION_MINOR 19 )
set( LOMSE_VERSION_PATCH 0 )

# build version string for installer name
set( LOMSE_PACKAGE_VERSION "${LOMSE_VERSION_MAJOR}.${LOMSE_VERSION_MINOR}.${LOMSE_VERSION_PATCH}" )
set( LOMSE_VERSION "${LOMSE_PACKAGE_VERSION}" )
set( LOMSE_VERSION_LONG "${LOMSE_VERSION}-nogit" )

message (STATUS "  Lomse version        = '${LOMSE_VERSION}'")
message (STATUS "  Lomse version string = '${LOMSE_PACKAGE_VERSION}'")

if (EXISTS ${LOMSE_ROOT_DIR}/.git)
  find_package (Git)
  if (NOT GIT_FOUND)
    message(SEND_ERROR "Git package not found." )
  else()
    # get sha1 and dirty status directly from git
    execute_process(COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
      WORKING_DIRECTORY "${LOMSE_ROOT_DIR}"
      OUTPUT_VARIABLE LOMSE_VERSION_BUILD
      OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --long --dirty
      WORKING_DIRECTORY "${LOMSE_ROOT_DIR}"
      OUTPUT_VARIABLE LOMSE_VERSION_GIT
      OUTPUT_STRIP_TRAILING_WHITESPACE)
    message (STATUS "  version git    = '${LOMSE_VERSION_GIT}'")
    if ( ${LOMSE_VERSION_GIT} MATCHES "-dirty$" )
      set (LOMSE_VERSION_BUILD "${LOMSE_VERSION_BUILD}-dirty")
    endif()
    if (NOT ".${LOMSE_VERSION_BUILD}" STREQUAL "." )
      set(LOMSE_VERSION_LONG "${LOMSE_PACKAGE_VERSION}+${LOMSE_VERSION_BUILD}")
    else()
      set(LOMSE_VERSION_LONG "${LOMSE_PACKAGE_VERSION}")
    endif()
  endif()
endif()
message (STATUS "  Lomse version long   = '${LOMSE_VERSION_LONG}'" )

# define a header file to pass version information to source code
configure_file(
    "${LOMSE_ROOT_DIR}/lomse_version.h.cmake"
    "${CMAKE_BINARY_DIR}/lomse_version.h"
)