CMakeLists.txt 2.3 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
2 3 4 5 6 7 8
PROJECT(TDengine)

INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY(. SRC)

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 53 54
FIND_PACKAGE(Git)
IF(GIT_FOUND)
  EXECUTE_PROCESS(
    COMMAND ${GIT_EXECUTABLE} log --pretty=oneline -n 1 ${CMAKE_CURRENT_LIST_DIR}/taosdump.c
    WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
    RESULT_VARIABLE RESULT
    OUTPUT_VARIABLE TAOSDUMP_COMMIT_SHA1
  )
  IF ("${TAOSDUMP_COMMIT_SHA1}" STREQUAL "")
    SET(TAOSDUMP_COMMIT_SHA1 "unknown")
  ELSE ()
    STRING(SUBSTRING "${TAOSDUMP_COMMIT_SHA1}" 0 7 TAOSDUMP_COMMIT_SHA1)
    STRING(STRIP "${TAOSDUMP_COMMIT_SHA1}" TAOSDUMP_COMMIT_SHA1)
  ENDIF ()
  EXECUTE_PROCESS(
    COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdump.c
    RESULT_VARIABLE RESULT
    OUTPUT_VARIABLE TAOSDUMP_STATUS
  )
  IF (TD_LINUX)
    EXECUTE_PROCESS(
      COMMAND bash "-c" "echo '${TAOSDUMP_STATUS}' | awk '{print $1}'"
      RESULT_VARIABLE RESULT
      OUTPUT_VARIABLE TAOSDUMP_STATUS
    )
  ENDIF (TD_LINUX)
ELSE()
  MESSAGE("Git not found")
  SET(TAOSDUMP_COMMIT_SHA1 "unknown")
  SET(TAOSDUMP_STATUS "unknown")
ENDIF (GIT_FOUND)

MESSAGE("taosdump's latest commit in short is:" ${TAOSDUMP_COMMIT_SHA1})
STRING(STRIP "${TAOSDUMP_STATUS}" TAOSDUMP_STATUS)

IF (TAOSDUMP_STATUS MATCHES "M")
  SET(TAOSDUMP_STATUS "modified")
ELSE()
  SET(TAOSDUMP_STATUS "")
ENDIF ()

MESSAGE("taosdump's status is:" ${TAOSDUMP_STATUS})

ADD_DEFINITIONS(-DTAOSDUMP_COMMIT_SHA1="${TAOSDUMP_COMMIT_SHA1}")
ADD_DEFINITIONS(-DTAOSDUMP_STATUS="${TAOSDUMP_STATUS}")

55 56
MESSAGE("TD_VER_NUMBER is:" ${TD_VER_NUMBER})
IF ("${TD_VER_NUMBER}" STREQUAL "")
57 58
    SET(TD_VERSION_NUMBER "TDengine-version-unknown")
ELSE()
59
    SET(TD_VERSION_NUMBER ${TD_VER_NUMBER})
60 61 62 63
ENDIF ()
MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER})
ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}")

64 65 66
IF (TD_LINUX)
  ADD_EXECUTABLE(taosdump ${SRC})
  IF (TD_SOMODE_STATIC)
67
    TARGET_LINK_LIBRARIES(taosdump taos_static cJson)
68
  ELSE ()
69
    TARGET_LINK_LIBRARIES(taosdump taos cJson)
70 71 72 73 74 75 76
  ENDIF ()
ENDIF ()

IF (TD_DARWIN)
  # missing <argp.h> for macosx
  # ADD_EXECUTABLE(taosdump ${SRC})
  # IF (TD_SOMODE_STATIC)
77
  #   TARGET_LINK_LIBRARIES(taosdump taos_static cJson)
78
  # ELSE ()
79
  #   TARGET_LINK_LIBRARIES(taosdump taos cJson)
80
  # ENDIF ()
81
ENDIF ()