CMakeLists.txt 3.0 KB
Newer Older
S
Shengliang Guan 已提交
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
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 12
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_COMMIT_SHA1)
13 14 15 16 17
    IF ("${TAOSDEMO_COMMIT_SHA1}" STREQUAL "")
        MESSAGE("taosdemo's latest commit in short is:" ${TAOSDEMO_COMMIT_SHA1})
    ELSE ()
        STRING(SUBSTRING "${TAOSDEMO_COMMIT_SHA1}" 0 7 TAOSDEMO_COMMIT_SHA1)
    ENDIF ()
18
    EXECUTE_PROCESS(
19
        COMMAND ${GIT_EXECUTABLE} status -z -s ${CMAKE_CURRENT_LIST_DIR}/taosdemo.c
20 21
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_STATUS)
22 23
    IF (TD_LINUX)
      EXECUTE_PROCESS(
24 25 26
        COMMAND bash "-c" "echo '${TAOSDEMO_STATUS}' | awk '{print $1}'"
        RESULT_VARIABLE RESULT
        OUTPUT_VARIABLE TAOSDEMO_STATUS)
27
    ENDIF (TD_LINUX)
28 29 30 31 32 33 34
    MESSAGE("taosdemo.c status: " ${TAOSDEMO_STATUS})
ELSE()
    MESSAGE("Git not found")
    SET(TAOSDEMO_COMMIT_SHA1 "unknown")
    SET(TAOSDEMO_STATUS "unknown")
ENDIF (GIT_FOUND)

35
STRING(STRIP "${TAOSDEMO_COMMIT_SHA1}" TAOSDEMO_COMMIT_SHA1)
36
MESSAGE("taosdemo's latest commit in short is:" ${TAOSDEMO_COMMIT_SHA1})
37
STRING(STRIP "${TAOSDEMO_STATUS}" TAOSDEMO_STATUS)
38 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}")

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

58 59 60 61 62 63 64
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 已提交
65
IF (TD_LINUX)
S
slguan 已提交
66
  AUX_SOURCE_DIRECTORY(. SRC)
67
  ADD_EXECUTABLE(taosdemo ${SRC})
68 69

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