CMakeLists.txt 3.0 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
H
hzcheng 已提交
2 3
PROJECT(TDengine)

S
slguan 已提交
4 5
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)

6 7 8 9
FIND_PACKAGE(Git)
IF (GIT_FOUND)
    MESSAGE("Git found")
    EXECUTE_PROCESS(
10
        COMMAND ${GIT_EXECUTABLE} log --pretty=oneline -n 1 ${CMAKE_CURRENT_LIST_DIR}/taosdemo.c
11
        WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
12 13
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_COMMIT_SHA1)
14
    IF ("${TAOSDEMO_COMMIT_SHA1}" STREQUAL "")
15
        SET(TAOSDEMO_COMMIT_SHA1 "unknown")
16 17
    ELSE ()
        STRING(SUBSTRING "${TAOSDEMO_COMMIT_SHA1}" 0 7 TAOSDEMO_COMMIT_SHA1)
18
        STRING(STRIP "${TAOSDEMO_COMMIT_SHA1}" TAOSDEMO_COMMIT_SHA1)
19
    ENDIF ()
20
    EXECUTE_PROCESS(
21
        COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdemo.c
22 23
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_STATUS)
24 25
    IF (TD_LINUX)
      EXECUTE_PROCESS(
26 27 28
        COMMAND bash "-c" "echo '${TAOSDEMO_STATUS}' | awk '{print $1}'"
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_STATUS)
29
    ENDIF (TD_LINUX)
30 31 32 33 34 35
ELSE()
    MESSAGE("Git not found")
    SET(TAOSDEMO_COMMIT_SHA1 "unknown")
    SET(TAOSDEMO_STATUS "unknown")
ENDIF (GIT_FOUND)

36

37
MESSAGE("taosdemo's latest commit in short is:" ${TAOSDEMO_COMMIT_SHA1})
38
STRING(STRIP "${TAOSDEMO_STATUS}" TAOSDEMO_STATUS)
39 40 41 42 43 44 45 46 47 48 49

IF (TAOSDEMO_STATUS MATCHES "M")
    SET(TAOSDEMO_STATUS "modified")
ELSE()
    SET(TAOSDEMO_STATUS "")
ENDIF ()
MESSAGE("taosdemo's status is:" ${TAOSDEMO_STATUS})

ADD_DEFINITIONS(-DTAOSDEMO_COMMIT_SHA1="${TAOSDEMO_COMMIT_SHA1}")
ADD_DEFINITIONS(-DTAOSDEMO_STATUS="${TAOSDEMO_STATUS}")

50 51
MESSAGE("TD_VER_NUMBER is:" ${TD_VER_NUMBER})
IF ("${TD_VER_NUMBER}" STREQUAL "")
52
    SET(TD_VERSION_NUMBER "TDengine-version-unknown")
53
ELSE()
54
    SET(TD_VERSION_NUMBER ${TD_VER_NUMBER})
55
ENDIF ()
56 57
MESSAGE("TD_VERSION_NUMBER is:" ${TD_VERSION_NUMBER})
ADD_DEFINITIONS(-DTD_VERNUMBER="${TD_VERSION_NUMBER}")
58

59 60 61 62 63 64 65
IF (TD_LINUX_64 AND JEMALLOC_ENABLED)
  ADD_DEFINITIONS(-DTD_JEMALLOC_ENABLED -I${CMAKE_BINARY_DIR}/build/include -L${CMAKE_BINARY_DIR}/build/lib -Wl,-rpath,${CMAKE_BINARY_DIR}/build/lib -ljemalloc)
  SET(LINK_JEMALLOC "-L${CMAKE_BINARY_DIR}/build/lib -ljemalloc")
ELSE ()
  SET(LINK_JEMALLOC "")
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
66
IF (TD_LINUX)
S
slguan 已提交
67
  AUX_SOURCE_DIRECTORY(. SRC)
68
  ADD_EXECUTABLE(taosdemo ${SRC})
69 70

  IF (TD_SOMODE_STATIC)
H
Haojun Liao 已提交
71
      TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua ${LINK_JEMALLOC})
72
  ELSE ()
73
      TARGET_LINK_LIBRARIES(taosdemo taos cJson ${LINK_JEMALLOC})
74
  ENDIF ()
75 76 77
ELSEIF (TD_WINDOWS)
  AUX_SOURCE_DIRECTORY(. SRC)
  ADD_EXECUTABLE(taosdemo ${SRC})
78 79
  SET_SOURCE_FILES_PROPERTIES(./taosdemo.c PROPERTIES COMPILE_FLAGS -w)
  IF (TD_SOMODE_STATIC)
Y
yihaoDeng 已提交
80
    TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua)
81
  ELSE ()
H
Haojun Liao 已提交
82
    TARGET_LINK_LIBRARIES(taosdemo taos cJson lua)
83
  ENDIF ()
84
ELSEIF (TD_DARWIN)
85
  # missing a few dependencies, such as <argp.h>
86 87 88 89
  AUX_SOURCE_DIRECTORY(. SRC)
  ADD_EXECUTABLE(taosdemo ${SRC})
  
  IF (TD_SOMODE_STATIC)
Y
yihaoDeng 已提交
90
    TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua)
91
  ELSE ()
Y
yihaoDeng 已提交
92
    TARGET_LINK_LIBRARIES(taosdemo taos cJson lua)
93
  ENDIF ()
94 95
ENDIF ()