version.inc 2.8 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
2 3
PROJECT(TDengine)

H
Hui Li 已提交
4 5 6
IF (DEFINED VERNUMBER)
  SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
haoranc's avatar
haoranc 已提交
7
  SET(TD_VER_NUMBER "2.0.20.19")
H
Hui Li 已提交
8
ENDIF ()
9

H
Hui Li 已提交
10 11 12 13 14
IF (DEFINED VERCOMPATIBLE)
  SET(TD_VER_COMPATIBLE ${VERCOMPATIBLE})
ELSE ()
  SET(TD_VER_COMPATIBLE "2.0.0.0")
ENDIF ()
15

16 17
find_program(HAVE_GIT NAMES git)

H
Hui Li 已提交
18 19
IF (DEFINED GITINFO)
  SET(TD_VER_GIT ${GITINFO})
20 21 22 23 24 25 26 27 28 29
ELSEIF (HAVE_GIT)
  execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${TD_COMMUNITY_DIR} OUTPUT_VARIABLE GIT_COMMITID)
  message(STATUS "git log result:${GIT_COMMITID}")
  IF (GIT_COMMITID)
    string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
    SET(TD_VER_GIT ${GIT_COMMITID})
  ELSE ()
    message(STATUS "not a git repository")
    SET(TD_VER_GIT "no git commit id")
  ENDIF ()
H
Hui Li 已提交
30
ELSE ()
31 32
  message(STATUS "no git cmd")
  SET(TD_VER_GIT "no git commit id")
33 34
ENDIF ()

H
Hui Li 已提交
35 36
IF (DEFINED GITINFOI)
  SET(TD_VER_GIT_INTERNAL ${GITINFOI})
37 38 39 40 41 42 43 44 45 46
ELSEIF (HAVE_GIT)
  execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID)
  message(STATUS "git log result:${GIT_COMMITID}")
  IF (GIT_COMMITID)
    string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
    SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
  ELSE ()
    message(STATUS "not a git repository")
    SET(TD_VER_GIT "no git commit id")
  ENDIF ()
H
Hui Li 已提交
47
ELSE ()
48 49
  message(STATUS "no git cmd")
  SET(TD_VER_GIT_INTERNAL "no git commit id")
50 51
ENDIF ()

H
Hui Li 已提交
52 53 54 55
IF (DEFINED VERDATE)
  SET(TD_VER_DATE ${VERDATE})
ELSE ()
  STRING(TIMESTAMP TD_VER_DATE "%Y-%m-%d %H:%M:%S") 
56 57
ENDIF ()

H
Hui Li 已提交
58 59 60 61
IF (DEFINED VERTYPE)
  SET(TD_VER_VERTYPE ${VERTYPE})
ELSE ()
  SET(TD_VER_VERTYPE "stable")
62
ENDIF ()
H
Hui Li 已提交
63 64 65 66

IF (DEFINED CPUTYPE)
  SET(TD_VER_CPUTYPE ${CPUTYPE})
ELSE ()
S
Shengliang Guan 已提交
67 68
  IF (TD_WINDOWS_32)
    SET(TD_VER_CPUTYPE "x86")
S
Shengliang Guan 已提交
69 70 71 72 73 74
  ELSEIF (TD_LINUX_32)
    SET(TD_VER_CPUTYPE "x86")  
  ELSEIF (TD_ARM_32)
    SET(TD_VER_CPUTYPE "x86")  
  ELSEIF (TD_MIPS_32)
    SET(TD_VER_CPUTYPE "x86")  
S
Shengliang Guan 已提交
75 76 77
  ELSE ()
    SET(TD_VER_CPUTYPE "x64")
  ENDIF ()
78 79
ENDIF ()

H
Hui Li 已提交
80 81 82 83
IF (DEFINED OSTYPE)
  SET(TD_VER_OSTYPE ${OSTYPE})
ELSE ()
  SET(TD_VER_OSTYPE "Linux")
84 85
ENDIF ()

H
Hui Li 已提交
86 87 88 89 90 91 92 93 94 95 96 97 98
MESSAGE(STATUS "============= compile version parameter information start ============= ")
MESSAGE(STATUS "ver number:" ${TD_VER_NUMBER})
MESSAGE(STATUS "compatible ver number:" ${TD_VER_COMPATIBLE})
MESSAGE(STATUS "communit commit id:" ${TD_VER_GIT})
MESSAGE(STATUS "internal commit id:" ${TD_VER_GIT_INTERNAL})
MESSAGE(STATUS "build date:" ${TD_VER_DATE})
MESSAGE(STATUS "ver type:" ${TD_VER_VERTYPE})
MESSAGE(STATUS "ver cpu:" ${TD_VER_CPUTYPE})
MESSAGE(STATUS "os type:" ${TD_VER_OSTYPE})
MESSAGE(STATUS "============= compile version parameter information end  ============= ")

STRING(REPLACE "." "_" TD_LIB_VER_NUMBER ${TD_VER_NUMBER})

99
CONFIGURE_FILE("${TD_COMMUNITY_DIR}/src/util/src/version.c.in" "${TD_COMMUNITY_DIR}/src/util/src/version.c")