define.inc 8.9 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
S
[TD-58]  
slguan 已提交
2 3 4
PROJECT(TDengine)

IF (TD_ACCOUNT)
S
slguan 已提交
5
  ADD_DEFINITIONS(-D_ACCT)
S
[TD-58]  
slguan 已提交
6 7
ENDIF ()

S
slguan 已提交
8 9 10 11
IF (TD_ADMIN)
  ADD_DEFINITIONS(-D_ADMIN)
ENDIF ()

S
[TD-63]  
slguan 已提交
12 13 14 15
IF (TD_GRANT)
  ADD_DEFINITIONS(-D_GRANT)
ENDIF ()

wafwerar's avatar
wafwerar 已提交
16 17 18 19
IF (TD_USB_DONGLE)
  ADD_DEFINITIONS(-D_USB_DONGLE)
ENDIF ()

S
TD-1310  
Shengliang Guan 已提交
20 21
IF (TD_MQTT)
  ADD_DEFINITIONS(-D_MQTT)
S
Shengliang Guan 已提交
22
ENDIF ()
S
Shengliang Guan 已提交
23

H
TD-1027  
Hongze Cheng 已提交
24 25
IF (TD_TSDB_PLUGINS)
  ADD_DEFINITIONS(-D_TSDB_PLUGINS)
S
TD-1310  
Shengliang Guan 已提交
26 27
ENDIF ()

S
TD-1767  
Shengliang Guan 已提交
28 29 30 31
IF (TD_STORAGE)
  ADD_DEFINITIONS(-D_STORAGE)
ENDIF ()

S
Shengliang Guan 已提交
32 33 34 35
IF (TD_TOPIC)
  ADD_DEFINITIONS(-D_TOPIC)
ENDIF ()

S
TD-3246  
Shengliang Guan 已提交
36 37 38 39
IF (TD_MODULE)
  ADD_DEFINITIONS(-D_MODULE)
ENDIF ()

S
[TD-58]  
slguan 已提交
40 41 42 43
IF (TD_GODLL)
  ADD_DEFINITIONS(-D_TD_GO_DLL_)
ENDIF ()

H
Hui Li 已提交
44 45
IF (TD_POWER)
  ADD_DEFINITIONS(-D_TD_POWER_)
H
Hui Li 已提交
46 47
ENDIF ()

48 49 50 51
IF (TD_TQ)
  ADD_DEFINITIONS(-D_TD_TQ_)
ENDIF ()

52 53 54 55
IF (TD_PRO)
  ADD_DEFINITIONS(-D_TD_PRO_)
ENDIF ()

56 57 58 59
IF (TD_KH)
  ADD_DEFINITIONS(-D_TD_KH_)
ENDIF ()

60 61 62 63
IF (TD_JH)
  ADD_DEFINITIONS(-D_TD_JH_)
ENDIF ()

S
[TD-58]  
slguan 已提交
64 65 66
IF (TD_MEM_CHECK)
  ADD_DEFINITIONS(-DTAOS_MEM_CHECK)
ENDIF ()
67 68 69 70

IF (TD_RANDOM_FILE_FAIL)
  ADD_DEFINITIONS(-DTAOS_RANDOM_FILE_FAIL)
ENDIF ()
71 72 73 74

IF (TD_RANDOM_NETWORK_FAIL)
  ADD_DEFINITIONS(-DTAOS_RANDOM_NETWORK_FAIL)
ENDIF ()
S
Shengliang Guan 已提交
75

S
Shengliang Guan 已提交
76 77 78
IF (TD_LINUX_64)
  ADD_DEFINITIONS(-D_M_X64)
  ADD_DEFINITIONS(-D_TD_LINUX_64)
S
TD-1530  
Shengliang Guan 已提交
79
  MESSAGE(STATUS "linux64 is defined")
80
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
81
  ADD_DEFINITIONS(-DUSE_LIBICONV)
82 83 84 85 86

  IF (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)
  ENDIF ()

S
Shengliang Guan 已提交
87 88 89 90 91
ENDIF ()

IF (TD_LINUX_32)
  ADD_DEFINITIONS(-D_TD_LINUX_32)
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
92
  MESSAGE(STATUS "linux32 is defined")
93
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
Shengliang Guan 已提交
94 95
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
96
IF (TD_ARM_64)
S
TD-1530  
Shengliang Guan 已提交
97
  ADD_DEFINITIONS(-D_TD_ARM_64)
S
Shengliang Guan 已提交
98
  ADD_DEFINITIONS(-D_TD_ARM_)
S
Shengliang Guan 已提交
99
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
100
  MESSAGE(STATUS "arm64 is defined")
101
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
102

Y
yihaoDeng 已提交
103
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src)
S
Shengliang Guan 已提交
104 105
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
106
IF (TD_ARM_32)
S
TD-1530  
Shengliang Guan 已提交
107
  ADD_DEFINITIONS(-D_TD_ARM_32)
S
Shengliang Guan 已提交
108
  ADD_DEFINITIONS(-D_TD_ARM_)
S
TD-1530  
Shengliang Guan 已提交
109
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
110
  MESSAGE(STATUS "arm32 is defined")
111
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types ")
Y
yihaoDeng 已提交
112 113

  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src)
S
TD-1057  
Shengliang Guan 已提交
114 115 116
ENDIF ()

IF (TD_MIPS_64)
117 118
  ADD_DEFINITIONS(-D_TD_MIPS_)
  ADD_DEFINITIONS(-D_TD_MIPS_64)
S
TD-1530  
Shengliang Guan 已提交
119
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
120
  MESSAGE(STATUS "mips64 is defined")
121
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
TD-1057  
Shengliang Guan 已提交
122 123 124
ENDIF ()

IF (TD_MIPS_32)
125 126
  ADD_DEFINITIONS(-D_TD_MIPS_)
  ADD_DEFINITIONS(-D_TD_MIPS_32)
S
TD-1530  
Shengliang Guan 已提交
127
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
128
  MESSAGE(STATUS "mips32 is defined")
129
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
Shengliang Guan 已提交
130 131
ENDIF ()

132
IF (TD_ALPINE)
S
TD-1057  
Shengliang Guan 已提交
133 134 135
  SET(COMMON_FLAGS "${COMMON_FLAGS} -largp")
  link_libraries(/usr/lib/libargp.a)
  ADD_DEFINITIONS(-D_ALPINE)
S
TD-1530  
Shengliang Guan 已提交
136
  MESSAGE(STATUS "aplhine is defined")
S
Shengliang Guan 已提交
137 138
ENDIF ()

139 140 141
IF ("${BUILD_HTTP}" STREQUAL "")
  IF (TD_LINUX)
    IF (TD_ARM_32)
142
      SET(TD_BUILD_HTTP TRUE)
143
    ELSE ()
144
      SET(TD_BUILD_HTTP TRUE)
145
    ENDIF ()
146
  ELSEIF (TD_DARWIN)
147
    SET(TD_BUILD_HTTP TRUE)
148
  ELSE ()
149
    SET(TD_BUILD_HTTP TRUE)
150
  ENDIF ()
151 152
ELSEIF (${BUILD_HTTP} MATCHES "false")
  SET(TD_BUILD_HTTP FALSE)
153 154
ELSEIF (${BUILD_HTTP} MATCHES "true")
  SET(TD_BUILD_HTTP TRUE)
155 156 157
ELSEIF (${BUILD_HTTP} MATCHES "internal")
  SET(TD_BUILD_HTTP FALSE)
  SET(TD_BUILD_TAOSA_INTERNAL TRUE)
158 159
ELSE ()
  SET(TD_BUILD_HTTP TRUE)
160 161 162
ENDIF ()

IF (TD_BUILD_HTTP)
163 164 165
  ADD_DEFINITIONS(-DHTTP_EMBEDDED)
ENDIF ()

166 167 168 169 170 171 172
IF ("${BUILD_TOOLS}" STREQUAL "")
  IF (TD_LINUX)
    IF (TD_ARM_32)
      SET(BUILD_TOOLS "false")
    ELSEIF (TD_ARM_64)
      SET(BUILD_TOOLS "false")
    ELSE ()
173
      SET(BUILD_TOOLS "false")
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    ENDIF ()
  ELSEIF (TD_DARWIN)
    SET(BUILD_TOOLS "false")
  ELSE ()
    SET(BUILD_TOOLS "false")
  ENDIF ()
ENDIF ()

IF ("${BUILD_TOOLS}" MATCHES "false")
    MESSAGE("${Yellow} Will _not_ build taos_tools! ${ColourReset}")
    SET(TD_TAOS_TOOLS FALSE)
ELSE ()
    MESSAGE("")
    MESSAGE("${Green} Will build taos_tools! ${ColourReset}")
    MESSAGE("")
    SET(TD_TAOS_TOOLS TRUE)
ENDIF ()

192 193 194 195 196 197 198
IF (${BUILD_LUA} MATCHES "false")
  SET(TD_BUILD_LUA FALSE)
ENDIF ()

IF (TD_BUILD_LUA)
  MESSAGE("Enable lua")
  ADD_DEFINITIONS(-DLUA_EMBEDDED)
199
  SET(LINK_LUA "lua")
200 201
ELSE ()
  MESSAGE("Disable lua")
202
  SET(LINK_LUA "")
203 204
ENDIF ()

S
Shengliang Guan 已提交
205 206
IF (TD_LINUX)
  ADD_DEFINITIONS(-DLINUX)
S
TD-1057  
Shengliang Guan 已提交
207
  ADD_DEFINITIONS(-D_LINUX)
S
Shengliang Guan 已提交
208 209
  ADD_DEFINITIONS(-D_TD_LINUX)
  ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
H
Hui Li 已提交
210 211

  IF (TD_NINGSI_60)
S
TD-1530  
Shengliang Guan 已提交
212
    ADD_DEFINITIONS(-D_TD_NINGSI_60)
H
Hui Li 已提交
213 214
    MESSAGE(STATUS "set ningsi macro to true")
  ENDIF ()
215 216

  IF (TD_MEMORY_SANITIZER)
217 218 219 220 221
    IF (TD_ARCHLINUX)
      SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG")
    ELSE ()
      SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -O0 -g3 -DDEBUG")
    ENDIF ()
222
    MESSAGE(STATUS "${BoldRed}Will compile with memory sanitizer! ${ColourReset}")
223 224 225
  ELSE ()
    SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG")
  ENDIF ()
S
Shengliang Guan 已提交
226
  SET(RELEASE_FLAGS "-O3 -Wno-error")
227

S
Shengliang Guan 已提交
228 229 230 231 232 233
  IF (${COVER} MATCHES "true")
    MESSAGE(STATUS "Test coverage mode, add extra flags")
    SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
    SET(GCC_COVERAGE_LINK_FLAGS    "-lgcov --coverage")
    SET(COMMON_FLAGS "${COMMON_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
  ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
234 235 236

  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc)
Y
yihaoDeng 已提交
237
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src)
S
Shengliang Guan 已提交
238 239 240 241 242 243 244
ENDIF ()

IF (TD_DARWIN_64)
  ADD_DEFINITIONS(-D_TD_DARWIN_64)
  ADD_DEFINITIONS(-DDARWIN)
  ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
245
  MESSAGE(STATUS "darwin64 is defined")
246 247 248 249 250
  IF ("${CPUTYPE}" STREQUAL "apple_m1")
    SET(COMMON_FLAGS "-Wall -Werror -Wno-missing-braces -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
  ELSE ()
    SET(COMMON_FLAGS "-Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
  ENDIF ()
251 252 253 254 255
  IF (TD_MEMORY_SANITIZER)
    SET(DEBUG_FLAGS "-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG")
  ELSE ()
    SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG")
  ENDIF ()
S
TD-1853  
Shengliang Guan 已提交
256
  SET(RELEASE_FLAGS "-Og")
257 258
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc)
Y
yihaoDeng 已提交
259
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src)
S
Shengliang Guan 已提交
260 261 262 263 264 265 266 267 268 269
ENDIF ()

IF (TD_WINDOWS)
  ADD_DEFINITIONS(-DWINDOWS)
  ADD_DEFINITIONS(-D__CLEANUP_C)
  ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
  ADD_DEFINITIONS(-DPTW32_BUILD)
  ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
  IF (NOT TD_GODLL)
270
    SET(COMMON_FLAGS "/nologo /WX /wd4018 /wd4999 /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
271 272 273
    IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
      SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
    ENDIF ()
274

275
    IF (TD_MEMORY_SANITIZER)
S
Shengliang Guan 已提交
276
      MESSAGE("memory sanitizer detected as true")
277 278
      SET(DEBUG_FLAGS "/fsanitize=address /Zi /W3 /GL")
    ELSE ()
S
Shengliang Guan 已提交
279
      MESSAGE("memory sanitizer detected as false")
280 281
      SET(DEBUG_FLAGS "/Zi /W3 /GL")
    ENDIF ()
282
    SET(RELEASE_FLAGS "/W0 /O2 /GL")  # MSVC only support O2
S
Shengliang Guan 已提交
283
  ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
284 285 286 287 288

  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/pthread)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/iconv)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/regex)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/wepoll/inc)
S
TD-1057  
Shengliang Guan 已提交
289
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MsvcLibX/include)
Y
yihaoDeng 已提交
290
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lua/src)
291
ENDIF ()
S
Shengliang Guan 已提交
292 293 294 295 296

IF (TD_WINDOWS_64)
  ADD_DEFINITIONS(-D_M_X64)
  ADD_DEFINITIONS(-D_TD_WINDOWS_64)
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
297
  MESSAGE(STATUS "windows64 is defined")
S
Shengliang Guan 已提交
298 299 300 301
ENDIF ()

IF (TD_WINDOWS_32)
  ADD_DEFINITIONS(-D_TD_WINDOWS_32)
302
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
303
  MESSAGE(STATUS "windows32 is defined")
S
Shengliang Guan 已提交
304 305
ENDIF ()

306 307 308 309
IF (TD_LINUX)
  SET(COMMON_FLAGS "${COMMON_FLAGS} -pipe -Wshadow")
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
310 311 312 313
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc)
S
TD-1057  
Shengliang Guan 已提交
314 315

MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID})