cmake.version 2.1 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4

IF (DEFINED VERNUMBER)
  SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
X
xleili 已提交
5
  SET(TD_VER_NUMBER "3.0.3.0")
S
Shengliang Guan 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
ENDIF ()

IF (DEFINED VERCOMPATIBLE)
  SET(TD_VER_COMPATIBLE ${VERCOMPATIBLE})
ELSE ()
  SET(TD_VER_COMPATIBLE "3.0.0.0")
ENDIF ()

find_program(HAVE_GIT NAMES git)

IF (DEFINED GITINFO)
  SET(TD_VER_GIT ${GITINFO})
ELSEIF (HAVE_GIT)
  execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${CMAKE_CURRENT_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 ${GIT_COMMITID})
  ELSE ()
    message(STATUS "not a git repository")
    SET(TD_VER_GIT "no git commit id")
  ENDIF ()
ELSE ()
H
Haojun Liao 已提交
29
  message(STATUS "no git found")
S
Shengliang Guan 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  SET(TD_VER_GIT "no git commit id")
ENDIF ()

IF (DEFINED VERDATE)
  SET(TD_VER_DATE ${VERDATE})
ELSE ()
  STRING(TIMESTAMP TD_VER_DATE "%Y-%m-%d %H:%M:%S") 
ENDIF ()

IF (DEFINED VERTYPE)
  SET(TD_VER_VERTYPE ${VERTYPE})
ELSE ()
  SET(TD_VER_VERTYPE "stable")
ENDIF ()

IF (DEFINED CPUTYPE)
  SET(TD_VER_CPUTYPE ${CPUTYPE})
ELSE ()
  IF (TD_WINDOWS_32)
    SET(TD_VER_CPUTYPE "x86")
  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")  
  ELSE ()
    SET(TD_VER_CPUTYPE "x64")
  ENDIF ()
ENDIF ()

IF (DEFINED OSTYPE)
  SET(TD_VER_OSTYPE ${OSTYPE})
ELSE ()
  SET(TD_VER_OSTYPE "Linux")
ENDIF ()

MESSAGE(STATUS "============= compile version parameter information start ============= ")
H
Haojun Liao 已提交
68 69 70 71 72
MESSAGE(STATUS "version:    " ${TD_VER_NUMBER})
MESSAGE(STATUS "compatible: " ${TD_VER_COMPATIBLE})
MESSAGE(STATUS "commit id:  " ${TD_VER_GIT})
MESSAGE(STATUS "build date: " ${TD_VER_DATE})
MESSAGE(STATUS "build type: " ${CMAKE_BUILD_TYPE})
H
Haojun Liao 已提交
73 74 75
MESSAGE(STATUS "type:       " ${TD_VER_VERTYPE})
MESSAGE(STATUS "cpu:        " ${TD_VER_CPUTYPE})
MESSAGE(STATUS "os:         " ${TD_VER_OSTYPE})
S
Shengliang Guan 已提交
76 77 78
MESSAGE(STATUS "============= compile version parameter information end  ============= ")

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