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

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

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

37

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

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}")

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

60 61 62 63 64 65 66
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 已提交
67
IF (TD_LINUX)
Z
zhaoyanggh 已提交
68
  AUX_SOURCE_DIRECTORY(./src SRC)
69
  ADD_EXECUTABLE(taosdemo ${SRC})
70 71

  IF (TD_SOMODE_STATIC)
H
Haojun Liao 已提交
72
      TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua ${LINK_JEMALLOC})
73
  ELSE ()
74
      TARGET_LINK_LIBRARIES(taosdemo taos cJson ${LINK_JEMALLOC})
75
  ENDIF ()
76
ELSEIF (TD_WINDOWS)
Z
zhaoyanggh 已提交
77
  AUX_SOURCE_DIRECTORY(./src SRC)
78
  ADD_EXECUTABLE(taosdemo ${SRC})
Z
zhaoyanggh 已提交
79
  SET_SOURCE_FILES_PROPERTIES(./src/demoUtil.c PROPERTIES COMPILE_FLAGS -w)
Z
zhaoyanggh 已提交
80
  SET_SOURCE_FILES_PROPERTIES(./src/demoData.c PROPERTIES COMPILE_FLAGS -w)
Z
zhaoyanggh 已提交
81 82 83 84 85 86 87
  SET_SOURCE_FILES_PROPERTIES(./src/demoInsert.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoCommandOpt.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoQuery.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoMain.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoSubscribe.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoOutput.c PROPERTIES COMPILE_FLAGS -w)
  SET_SOURCE_FILES_PROPERTIES(./src/demoJsonOpt.c PROPERTIES COMPILE_FLAGS -w)
88
  IF (TD_SOMODE_STATIC)
Y
yihaoDeng 已提交
89
    TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua)
90
  ELSE ()
H
Haojun Liao 已提交
91
    TARGET_LINK_LIBRARIES(taosdemo taos cJson lua)
92
  ENDIF ()
93
ELSEIF (TD_DARWIN)
94
  # missing a few dependencies, such as <argp.h>
Z
zhaoyanggh 已提交
95
  AUX_SOURCE_DIRECTORY(./src SRC)
96 97 98
  ADD_EXECUTABLE(taosdemo ${SRC})
  
  IF (TD_SOMODE_STATIC)
Y
yihaoDeng 已提交
99
    TARGET_LINK_LIBRARIES(taosdemo taos_static cJson lua)
100
  ELSE ()
Y
yihaoDeng 已提交
101
    TARGET_LINK_LIBRARIES(taosdemo taos cJson lua)
102
  ENDIF ()
103 104
ENDIF ()