cmake.define 2.2 KB
Newer Older
1 2
cmake_minimum_required(VERSION 3.16)

wafwerar's avatar
wafwerar 已提交
3 4 5 6 7 8 9 10 11 12
if (NOT DEFINED TD_GRANT)
  SET(TD_GRANT FALSE)
endif()
if (NOT DEFINED TD_USB_DONGLE)
  SET(TD_USB_DONGLE FALSE)
endif()
IF (TD_GRANT)
  ADD_DEFINITIONS(-D_GRANT)
ENDIF ()

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 42 43 44 45 46 47 48
IF ("${BUILD_TOOLS}" STREQUAL "")
  IF (TD_LINUX)
    IF (TD_ARM_32)
      SET(BUILD_TOOLS "false")
    ELSEIF (TD_ARM_64)
      SET(BUILD_TOOLS "false")
    ELSE ()
      SET(BUILD_TOOLS "false")
    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 ()

IF (TD_WINDOWS)
    MESSAGE("${Yellow} set compiler flag for Windows! ${ColourReset}")
    SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
    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-")

    IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
      SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
    ENDIF ()

ELSE ()
49 50 51 52
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
    #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -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 -g3")
    #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -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 -g3")
53 54

MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
wmmhello's avatar
wmmhello 已提交
55
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
56 57 58 59
    ADD_DEFINITIONS("-D_TD_ARM_")
ELSE ()
    ADD_DEFINITIONS("-msse4.2 -mfma")
ENDIF ()
60 61

ENDIF ()