define.inc 6.6 KB
Newer Older
S
[TD-58]  
slguan 已提交
1 2 3 4
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
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 ()

S
TD-1310  
Shengliang Guan 已提交
16 17
IF (TD_MQTT)
  ADD_DEFINITIONS(-D_MQTT)
S
Shengliang Guan 已提交
18
ENDIF ()
S
Shengliang Guan 已提交
19

H
TD-1027  
Hongze Cheng 已提交
20 21
IF (TD_TSDB_PLUGINS)
  ADD_DEFINITIONS(-D_TSDB_PLUGINS)
S
TD-1310  
Shengliang Guan 已提交
22 23
ENDIF ()

S
TD-1767  
Shengliang Guan 已提交
24 25 26 27
IF (TD_STORAGE)
  ADD_DEFINITIONS(-D_STORAGE)
ENDIF ()

S
Shengliang Guan 已提交
28 29 30 31
IF (TD_TOPIC)
  ADD_DEFINITIONS(-D_TOPIC)
ENDIF ()

S
TD-3246  
Shengliang Guan 已提交
32 33 34 35
IF (TD_MODULE)
  ADD_DEFINITIONS(-D_MODULE)
ENDIF ()

S
[TD-58]  
slguan 已提交
36 37 38 39
IF (TD_GODLL)
  ADD_DEFINITIONS(-D_TD_GO_DLL_)
ENDIF ()

H
Hui Li 已提交
40 41
IF (TD_POWER)
  ADD_DEFINITIONS(-D_TD_POWER_)
H
Hui Li 已提交
42 43
ENDIF ()

44 45 46 47
IF (TD_TQ)
  ADD_DEFINITIONS(-D_TD_TQ_)
ENDIF ()

S
[TD-58]  
slguan 已提交
48 49 50
IF (TD_MEM_CHECK)
  ADD_DEFINITIONS(-DTAOS_MEM_CHECK)
ENDIF ()
51 52 53 54

IF (TD_RANDOM_FILE_FAIL)
  ADD_DEFINITIONS(-DTAOS_RANDOM_FILE_FAIL)
ENDIF ()
55 56 57 58

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

S
Shengliang Guan 已提交
60 61 62
IF (TD_LINUX_64)
  ADD_DEFINITIONS(-D_M_X64)
  ADD_DEFINITIONS(-D_TD_LINUX_64)
S
TD-1530  
Shengliang Guan 已提交
63
  MESSAGE(STATUS "linux64 is defined")
64
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
65
  ADD_DEFINITIONS(-DUSE_LIBICONV)
66 67 68 69 70

  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 已提交
71 72 73 74 75
ENDIF ()

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

S
TD-1057  
Shengliang Guan 已提交
80
IF (TD_ARM_64)
S
TD-1530  
Shengliang Guan 已提交
81
  ADD_DEFINITIONS(-D_TD_ARM_64)
S
Shengliang Guan 已提交
82
  ADD_DEFINITIONS(-D_TD_ARM_)
S
Shengliang Guan 已提交
83
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
84
  MESSAGE(STATUS "arm64 is defined")
85
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
Shengliang Guan 已提交
86 87
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
88
IF (TD_ARM_32)
S
TD-1530  
Shengliang Guan 已提交
89
  ADD_DEFINITIONS(-D_TD_ARM_32)
S
Shengliang Guan 已提交
90
  ADD_DEFINITIONS(-D_TD_ARM_)
S
TD-1530  
Shengliang Guan 已提交
91
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
92
  MESSAGE(STATUS "arm32 is defined")
93
  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 ")
S
TD-1057  
Shengliang Guan 已提交
94 95 96
ENDIF ()

IF (TD_MIPS_64)
97 98
  ADD_DEFINITIONS(-D_TD_MIPS_)
  ADD_DEFINITIONS(-D_TD_MIPS_64)
S
TD-1530  
Shengliang Guan 已提交
99
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
100
  MESSAGE(STATUS "mips64 is defined")
101
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
TD-1057  
Shengliang Guan 已提交
102 103 104
ENDIF ()

IF (TD_MIPS_32)
105 106
  ADD_DEFINITIONS(-D_TD_MIPS_)
  ADD_DEFINITIONS(-D_TD_MIPS_32)
S
TD-1530  
Shengliang Guan 已提交
107
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
108
  MESSAGE(STATUS "mips32 is defined")
109
  SET(COMMON_FLAGS "-Wall -Werror -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
S
Shengliang Guan 已提交
110 111
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
112 113 114 115
IF (TD_APLHINE)
  SET(COMMON_FLAGS "${COMMON_FLAGS} -largp")
  link_libraries(/usr/lib/libargp.a)
  ADD_DEFINITIONS(-D_ALPINE)
S
TD-1530  
Shengliang Guan 已提交
116
  MESSAGE(STATUS "aplhine is defined")
S
Shengliang Guan 已提交
117 118 119 120
ENDIF ()

IF (TD_LINUX)
  ADD_DEFINITIONS(-DLINUX)
S
TD-1057  
Shengliang Guan 已提交
121
  ADD_DEFINITIONS(-D_LINUX)
S
Shengliang Guan 已提交
122 123
  ADD_DEFINITIONS(-D_TD_LINUX)
  ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
H
Hui Li 已提交
124 125

  IF (TD_NINGSI_60)
S
TD-1530  
Shengliang Guan 已提交
126
    ADD_DEFINITIONS(-D_TD_NINGSI_60)
H
Hui Li 已提交
127 128
    MESSAGE(STATUS "set ningsi macro to true")
  ENDIF ()
129 130 131 132 133 134

  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 -static-libasan -O0 -g3 -DDEBUG")
  ELSE ()
    SET(DEBUG_FLAGS "-O0 -g3 -DDEBUG")
  ENDIF ()
S
Shengliang Guan 已提交
135
  SET(RELEASE_FLAGS "-O3 -Wno-error")
136

S
Shengliang Guan 已提交
137 138 139 140 141 142
  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 已提交
143 144 145

  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc)
S
Shengliang Guan 已提交
146 147 148 149 150 151 152
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 已提交
153
  MESSAGE(STATUS "darwin64 is defined")
154 155 156 157 158
  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 ()
159 160 161 162 163
  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 已提交
164
  SET(RELEASE_FLAGS "-Og")
165 166
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/cJson/inc)
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/lz4/inc)
S
Shengliang Guan 已提交
167 168 169 170 171 172 173 174 175 176
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)
177
    SET(COMMON_FLAGS "/nologo /WX /wd4018 /wd2220 /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
178 179 180
    IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
      SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
    ENDIF ()
181

182
    IF (TD_MEMORY_SANITIZER)
S
Shengliang Guan 已提交
183
      MESSAGE("memory sanitizer detected as true")
184 185
      SET(DEBUG_FLAGS "/fsanitize=address /Zi /W3 /GL")
    ELSE ()
S
Shengliang Guan 已提交
186
      MESSAGE("memory sanitizer detected as false")
187 188
      SET(DEBUG_FLAGS "/Zi /W3 /GL")
    ENDIF ()
189
    SET(RELEASE_FLAGS "/W0 /O2 /GL")  # MSVC only support O2
S
Shengliang Guan 已提交
190
  ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
191 192 193 194 195

  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 已提交
196
  INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MsvcLibX/include)
197
ENDIF ()
S
Shengliang Guan 已提交
198 199 200 201 202

IF (TD_WINDOWS_64)
  ADD_DEFINITIONS(-D_M_X64)
  ADD_DEFINITIONS(-D_TD_WINDOWS_64)
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
203
  MESSAGE(STATUS "windows64 is defined")
S
Shengliang Guan 已提交
204 205 206 207
ENDIF ()

IF (TD_WINDOWS_32)
  ADD_DEFINITIONS(-D_TD_WINDOWS_32)
208
  ADD_DEFINITIONS(-DUSE_LIBICONV)
S
TD-1530  
Shengliang Guan 已提交
209
  MESSAGE(STATUS "windows32 is defined")
S
Shengliang Guan 已提交
210 211
ENDIF ()

212 213 214 215
IF (TD_LINUX)
  SET(COMMON_FLAGS "${COMMON_FLAGS} -pipe -Wshadow")
ENDIF ()

S
TD-1057  
Shengliang Guan 已提交
216 217 218 219
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 已提交
220 221

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