CMakeLists.txt 2.1 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
S
slguan 已提交
2 3 4
PROJECT(TDengine)

ADD_SUBDIRECTORY(monitor)
5 6

IF (TD_BUILD_HTTP)
7 8 9
  MESSAGE("")
  MESSAGE("${Yellow} use original embedded httpd ${ColourReset}")
  MESSAGE("")
10
  ADD_SUBDIRECTORY(http)
11 12
ELSE ()
  MESSAGE("")
13
  MESSAGE("${Green} use taosadapter as httpd ${ColourReset}")
14
  EXECUTE_PROCESS(
15
      COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
16 17 18 19
      )
  EXECUTE_PROCESS(
      COMMAND git rev-parse --short HEAD
      RESULT_VARIABLE commit_sha1
20
      OUTPUT_VARIABLE taosadapter_commit_sha1
21
      )
22 23
  IF ("${taosadapter_commit_sha1}" STREQUAL "")
        SET(taosadapter_commit_sha1 "unknown")
24
  ELSE ()
25 26
        STRING(SUBSTRING "${taosadapter_commit_sha1}" 0 7 taosadapter_commit_sha1)
        STRING(STRIP "${taosadapter_commit_sha1}" taosadapter_commit_sha1)
27
  ENDIF ()
28
  MESSAGE("${Green} taosadapter commit: ${taosadapter_commit_sha1} ${ColourReset}")
29 30 31
  EXECUTE_PROCESS(
      COMMAND cd ..
      )
32
  include(ExternalProject)
33 34 35
  ExternalProject_Add(taosadapter
    PREFIX        "taosadapter"
    SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
36 37 38
    BUILD_ALWAYS         off
    DEPENDS             taos
    BUILD_IN_SOURCE     1
39
    CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
40 41
    PATCH_COMMAND
        COMMAND     git clean -f -d
42
    BUILD_COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../inc CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -ldflags "-s -w -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
43
    INSTALL_COMMAND
44
        COMMAND curl -sL https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz -o upx.tar.xz && tar xvJf upx.tar.xz --strip-components 1 > /dev/null && ./upx taosadapter || :
45
        COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
46
        COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
47 48
        COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
        COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
49
  )
50 51
ENDIF ()

S
TD-1207  
Shengliang Guan 已提交
52
IF (TD_LINUX AND TD_MQTT)
S
TD-1310  
Shengliang Guan 已提交
53
  ADD_SUBDIRECTORY(mqtt)
54
ENDIF ()