CMakeLists.txt 10.0 KB
Newer Older
1
IF (TD_WEBSOCKET)
2
    MESSAGE("${Green} use libtaos-ws${ColourReset}")
3 4 5 6 7 8 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
    IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD")
        include(ExternalProject)
        ExternalProject_Add(taosws-rs
            PREFIX        "taosws-rs"
            SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
            BUILD_ALWAYS         off
            DEPENDS             taos
            BUILD_IN_SOURCE     1
            CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
            PATCH_COMMAND
            COMMAND     git clean -f -d
            BUILD_COMMAND
            COMMAND cargo build --release -p taos-ws-sys
            COMMAND ./taos-ws-sys/ci/package.sh
            INSTALL_COMMAND
            COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib
            COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
            COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
            )
    ELSE()
        include(ExternalProject)
        ExternalProject_Add(taosws-rs
            PREFIX        "taosws-rs"
            SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
            BUILD_ALWAYS         on
            DEPENDS             taos
            BUILD_IN_SOURCE     1
            CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
            PATCH_COMMAND
            COMMAND     git clean -f -d
            BUILD_COMMAND
            COMMAND cargo build --release -p taos-ws-sys
            COMMAND ./taos-ws-sys/ci/package.sh
            INSTALL_COMMAND
            COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib
            COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
            COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include
            )
    ENDIF ()
42 43
ENDIF ()

44
IF (TD_TAOS_TOOLS)
wafwerar's avatar
wafwerar 已提交
45 46 47 48 49 50
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/tools/taos_tools/deps/avro/lang/c/src)
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/client)
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/common)
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/util)
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/os)
    INCLUDE_DIRECTORIES(${TD_SOURCE_DIR}/include/libs/transport)
51 52 53 54
    ADD_SUBDIRECTORY(taos-tools)
ENDIF ()

add_subdirectory(shell)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
IF (TD_BUILD_HTTP)
    MESSAGE("")
    MESSAGE("${Yellow} use original embedded httpd ${ColourReset}")
    MESSAGE("")
    #    ADD_SUBDIRECTORY(http)
ELSEIF(TD_BUILD_TAOSA_INTERNAL)
    MESSAGE("${Yellow} use taosa internal as httpd ${ColourReset}")
ELSE ()
    MESSAGE("")
    MESSAGE("${Green} use taosadapter as httpd, platform is ${PLATFORM_ARCH_STR} ${ColourReset}")

    EXECUTE_PROCESS(
            COMMAND  git rev-parse --abbrev-ref HEAD
            RESULT_VARIABLE result_taos_version
            OUTPUT_VARIABLE taos_version
    )

    STRING(FIND ${taos_version} release is_release_branch)

    IF ("${is_release_branch}" STREQUAL "0")
        STRING(SUBSTRING "${taos_version}" 12 -1 taos_version)
        STRING(STRIP "${taos_version}" taos_version)
    ELSE ()
        STRING(CONCAT taos_version "_branch_" "${taos_version}")
        STRING(STRIP "${taos_version}" taos_version)
    ENDIF ()
    EXECUTE_PROCESS(
            COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
    )
    EXECUTE_PROCESS(
            COMMAND git rev-parse --short HEAD
            RESULT_VARIABLE commit_sha1
            OUTPUT_VARIABLE taosadapter_commit_sha1
    )
    IF ("${taosadapter_commit_sha1}" STREQUAL "")
        SET(taosadapter_commit_sha1 "unknown")
    ELSE ()
        STRING(SUBSTRING "${taosadapter_commit_sha1}" 0 7 taosadapter_commit_sha1)
        STRING(STRIP "${taosadapter_commit_sha1}" taosadapter_commit_sha1)
    ENDIF ()
    MESSAGE("${Green} taosAdapter will use ${taos_version} and commit ${taosadapter_commit_sha1} as version ${ColourReset}")
    EXECUTE_PROCESS(
            COMMAND cd ..
    )
    MESSAGE("CURRENT SOURCE DIR ${CMAKE_CURRENT_SOURCE_DIR}")
    IF (TD_LINUX)
        include(ExternalProject)
102 103 104 105 106 107 108 109 110
        set(_upx_prefix "$ENV{HOME}/.taos/externals/upx")
        ExternalProject_Add(upx
            PREFIX              "${_upx_prefix}"
            URL                 https://github.com/upx/upx/releases/download/v3.96/upx-3.96-${PLATFORM_ARCH_STR}_linux.tar.xz
            CONFIGURE_COMMAND   cmake -E true
            BUILD_COMMAND       cmake -E true
            INSTALL_COMMAND     cmake -E true
            )

111 112 113 114
        ExternalProject_Add(taosadapter
                PREFIX        "taosadapter"
                SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
                BUILD_ALWAYS         off
115
                DEPENDS             taos upx
116 117 118 119 120 121 122 123
                BUILD_IN_SOURCE     1
                CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
                PATCH_COMMAND
                COMMAND     git clean -f -d
                BUILD_COMMAND
                COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -a -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
                COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -a -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
                INSTALL_COMMAND
124
                COMMAND ${_upx_prefix}/src/upx/upx taosadapter
125 126 127 128 129 130
                COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
                COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
                )
131
        unset(_upx_prefix)
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    ELSEIF (TD_DARWIN)
        include(ExternalProject)
        ExternalProject_Add(taosadapter
                PREFIX        "taosadapter"
                SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
                BUILD_ALWAYS         off
                DEPENDS             taos
                BUILD_IN_SOURCE     1
                CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
                PATCH_COMMAND
                COMMAND     git clean -f -d
                BUILD_COMMAND
                COMMAND    CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -a -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
                COMMAND    CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -a -o taosadapter-debug -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
                INSTALL_COMMAND
                COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
                COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
                )
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
#        unset(_upx_prefix)
    ELSEIF (TD_WINDOWS)
        include(ExternalProject)
        set(_upx_prefix "${CMAKE_BINARY_DIR}/.taos/externals/upx")
        ExternalProject_Add(upx
                PREFIX              "${_upx_prefix}"
                URL                 https://github.com/upx/upx/releases/download/v3.96/upx-3.96-win32.zip
                CONFIGURE_COMMAND   cmake -E true
                BUILD_COMMAND       cmake -E true
                INSTALL_COMMAND     cmake -E true
                )

        ExternalProject_Add(taosadapter
                PREFIX        "taosadapter"
                SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
                BUILD_ALWAYS         off
                DEPENDS             taos
                BUILD_IN_SOURCE     1
                CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
                PATCH_COMMAND
                COMMAND     git clean -f -d
                BUILD_COMMAND
                COMMAND set CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client
                COMMAND set CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib
177 178
                COMMAND go build -a -o taosadapter.exe -ldflags "-s -w -X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
                COMMAND go build -a -o taosadapter-debug.exe -ldflags "-X github.com/taosdata/taosadapter/version.Version=${taos_version} -X github.com/taosdata/taosadapter/version.CommitID=${taosadapter_commit_sha1}"
179 180 181 182 183 184
                INSTALL_COMMAND
                COMMAND ${_upx_prefix}/src/upx/upx taosadapter.exe
                COMMAND cmake -E copy taosadapter.exe ${CMAKE_BINARY_DIR}/build/bin
                COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
                COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
185
                COMMAND cmake -E copy taosadapter-debug.exe ${CMAKE_BINARY_DIR}/build/bin
186
                )
187
        unset(_upx_prefix)
188
    ELSE ()
189
        MESSAGE("${Yellow} taosAdapter Not supported yet  ${ColourReset}")
190 191
    ENDIF ()
ENDIF ()