CMakeLists.txt 7.4 KB
Newer Older
1
IF (TD_WEBSOCKET)
wafwerar's avatar
wafwerar 已提交
2 3 4 5
    IF (TD_LINUX)
        SET(websocket_lib_file "libtaosws.so")
    ELSEIF (TD_DARWIN)
        SET(websocket_lib_file "libtaosws.dylib")
wafwerar's avatar
wafwerar 已提交
6 7
    ELSEIF (TD_WINDOWS)
        SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}")
wafwerar's avatar
wafwerar 已提交
8
    ENDIF ()
9
    MESSAGE("${Green} use libtaos-ws${ColourReset}")
wafwerar's avatar
wafwerar 已提交
10 11 12 13 14

    include(ExternalProject)
    ExternalProject_Add(taosws-rs
        PREFIX        "taosws-rs"
        SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
15
        BUILD_ALWAYS        off
wafwerar's avatar
wafwerar 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28
        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 update
        COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored
        INSTALL_COMMAND
        COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
        COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
        COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include
        )
29 30
ENDIF ()

31
IF (TD_TAOS_TOOLS)
wafwerar's avatar
wafwerar 已提交
32 33 34 35 36 37
    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)
38 39 40 41
    ADD_SUBDIRECTORY(taos-tools)
ENDIF ()

add_subdirectory(shell)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
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(
72
            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
            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}")
88

89
    IF (TD_WINDOWS)
90
        MESSAGE("Building taosAdapter on Windows")
91 92 93 94 95 96 97 98 99 100 101 102 103
        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 set CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client
            COMMAND set CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib
104 105 106
            COMMAND go build -a -o taosadapter.exe -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
#            COMMAND go build -a -o taosadapter.exe -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
#            COMMAND go build -a -o taosadapter-debug.exe -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
107

108
            INSTALL_COMMAND
109 110
#            COMMAND cmake -E echo "Comparessing taosadapter.exe"
#            COMMAND cmake -E time upx taosadapter.exe
111 112
            COMMAND cmake -E echo "Copy taosadapter.exe"
            COMMAND cmake -E copy taosadapter.exe ${CMAKE_BINARY_DIR}/build/bin/taosadapter.exe
113
            COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
114
            COMMAND cmake -E echo "Copy taosadapter.toml"
115
            COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
116 117
#            COMMAND cmake -E echo "Copy taosadapter-debug.exe"
#            COMMAND cmake -E copy taosadapter-debug.exe ${CMAKE_BINARY_DIR}/build/bin
118 119
            )
    ELSE (TD_WINDOWS)
120
        MESSAGE("Building taosAdapter on non-Windows")
121 122
        INCLUDE(ExternalProject)
        ExternalProject_Add(taosadapter
wafwerar's avatar
wafwerar 已提交
123 124 125 126 127 128 129 130 131
            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
132 133 134
            COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib  go build -a -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/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 -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/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/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
wafwerar's avatar
wafwerar 已提交
135
            INSTALL_COMMAND
136 137
#            COMMAND cmake -E echo "Comparessing taosadapter.exe"
#            COMMAND upx taosadapter || :
138
            COMMAND cmake -E echo "Copy taosadapter"
wafwerar's avatar
wafwerar 已提交
139 140
            COMMAND cmake -E copy taosadapter ${CMAKE_BINARY_DIR}/build/bin
            COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
141
            COMMAND cmake -E echo "Copy taosadapter.toml"
wafwerar's avatar
wafwerar 已提交
142 143
            COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
            COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
144 145
#            COMMAND cmake -E echo "Copy taosadapter-debug"
#            COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
wafwerar's avatar
wafwerar 已提交
146
            )
147
    ENDIF (TD_WINDOWS)
148
ENDIF ()