blob: ca0716da7ee66671ad27af4227870fd08fe25f0e (
plain)
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
|
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
FUNCTION(GET_FILE_VERSION FILE_NAME FILE_VERSION)
# if we build from a git repository, we calculate the file version:
# Patch number is number of commits for given file
IF(GIT_EXECUTABLE AND EXISTS ${CC_SOURCE_DIR}/.git)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --git-dir=${CC_SOURCE_DIR}/.git --work-tree=${CC_SOURCE_DIR} rev-list HEAD --count -- ${FILE_NAME}
OUTPUT_VARIABLE FV)
STRING(REPLACE "\n" "" FV ${FV})
SET(${FILE_VERSION} ${FV} PARENT_SCOPE)
ELSE()
SET(${FILE_VERSION} 0)
ENDIF()
ENDFUNCTION()
MACRO(SET_VERSION_INFO)
SET(FILE_VERSION "0")
FOREACH(PROPERTY ${ARGN})
IF(${PROPERTY} MATCHES "TARGET:")
STRING(REGEX REPLACE "^[TARGET:\\s]" "" TARGET ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "FILE_TYPE:")
STRING(REGEX REPLACE "^[FILE_TYPE:\\s]" "" FILE_TYPE ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "ORIGINAL_FILE_NAME:")
STRING(REGEX REPLACE "^[ORIGINAL_FILE_NAME:\\s]" "" ORIGINAL_FILE_NAME ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "SOURCE_FILE:")
STRING(REGEX REPLACE "^[SOURCE_FILE:\\s]" "" SOURCE ${PROPERTY})
GET_FILE_VERSION(${SOURCE} FILE_VERSION)
ELSEIF(${PROPERTY} MATCHES "FILE_DESCRIPTION:")
STRING(REPLACE "FILE_DESCRIPTION:" "" FILE_DESCRIPTION ${PROPERTY})
ENDIF()
ENDFOREACH()
CONFIGURE_FILE(${CC_SOURCE_DIR}/win/resource.rc.in
${CC_BINARY_DIR}/win/${TARGET}.rc)
SET(${TARGET}_RC ${CC_BINARY_DIR}/win/${TARGET}.rc)
ENDMACRO()
|