2
# Gather version from tarball or SCM
4
# This module defines the following variables:
5
# PRODUCT_VERSION - Version of product
8
#=============================================================================
9
# Copyright 2011 O.S. Systems Software Ltda.
10
# Copyright 2011 Otavio Salvador <otavio@ossystems.com.br>
12
# Licensed under the Apache License, Version 2.0 (the "License");
13
# you may not use this file except in compliance with the License.
14
# You may obtain a copy of the License at
16
# http://www.apache.org/licenses/LICENSE-2.0
18
# Unless required by applicable law or agreed to in writing, software
19
# distributed under the License is distributed on an "AS IS" BASIS,
20
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
# See the License for the specific language governing permissions and
22
# limitations under the License.
23
#=============================================================================
25
if(EXISTS "${CMAKE_SOURCE_DIR}/.version" )
26
file(READ ${CMAKE_SOURCE_DIR}/.version PRODUCT_VERSION)
28
string(STRIP ${PRODUCT_VERSION} PRODUCT_VERSION)
30
execute_process(COMMAND git describe --match "v[0-9]*" --abbrev=4
31
OUTPUT_VARIABLE PRODUCT_VERSION
32
OUTPUT_STRIP_TRAILING_WHITESPACE
36
string(REGEX REPLACE "^v(.*)" "\\1" PRODUCT_VERSION ${PRODUCT_VERSION})
38
# GIT is the default version
39
set(PRODUCT_VERSION GIT)
42
# Check if has not commited changes
43
execute_process(COMMAND git update-index -q --refresh)
44
execute_process(COMMAND git diff-index --name-only HEAD --
45
OUTPUT_VARIABLE CHANGED_SOURCE
46
OUTPUT_STRIP_TRAILING_WHITESPACE
50
set(PRODUCT_VERSION ${PRODUCT_VERSION}-dirty)
54
message(STATUS "${CMAKE_PROJECT_NAME} ${PRODUCT_VERSION}")