cmake.define 4.3 KB
Newer Older
1
cmake_minimum_required(VERSION 3.0)
2

X
Xiaoyu Wang 已提交
3
set(CMAKE_VERBOSE_MAKEFILE OFF)
wafwerar's avatar
wafwerar 已提交
4

wafwerar's avatar
wafwerar 已提交
5 6
SET(BUILD_SHARED_LIBS "OFF")

wafwerar's avatar
wafwerar 已提交
7 8 9 10 11 12 13 14 15 16
#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)

MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})

wafwerar's avatar
wafwerar 已提交
17 18 19 20
if (NOT DEFINED TD_GRANT)
  SET(TD_GRANT FALSE)
endif()

21 22 23 24 25 26 27 28
IF ("${WEBSOCKET}" MATCHES "true")
    SET(TD_WEBSOCKET TRUE)
    MESSAGE("Enable websocket")
    ADD_DEFINITIONS(-DWEBSOCKET)
ELSE ()
    SET(TD_WEBSOCKET FALSE)
ENDIF ()

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
IF ("${BUILD_HTTP}" STREQUAL "")
  IF (TD_LINUX)
    IF (TD_ARM_32)
      SET(TD_BUILD_HTTP TRUE)
    ELSE ()
      SET(TD_BUILD_HTTP TRUE)
    ENDIF ()
  ELSEIF (TD_DARWIN)
    SET(TD_BUILD_HTTP TRUE)
  ELSE ()
    SET(TD_BUILD_HTTP TRUE)
  ENDIF ()
ELSEIF (${BUILD_HTTP} MATCHES "false")
  SET(TD_BUILD_HTTP FALSE)
ELSEIF (${BUILD_HTTP} MATCHES "true")
  SET(TD_BUILD_HTTP TRUE)
ELSEIF (${BUILD_HTTP} MATCHES "internal")
  SET(TD_BUILD_HTTP FALSE)
  SET(TD_BUILD_TAOSA_INTERNAL TRUE)
ELSE ()
  SET(TD_BUILD_HTTP TRUE)
ENDIF ()

IF (TD_BUILD_HTTP)
  ADD_DEFINITIONS(-DHTTP_EMBEDDED)
ENDIF ()

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
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}")
wafwerar's avatar
wafwerar 已提交
84
    SET(COMMON_FLAGS "/w /D_WIN32 /DWIN32 /Zi")
wafwerar's avatar
wafwerar 已提交
85
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
wafwerar's avatar
wafwerar 已提交
86 87 88
    # IF (MSVC AND (MSVC_VERSION GREATER_EQUAL 1900))
    #  SET(COMMON_FLAGS "${COMMON_FLAGS} /Wv:18")
    # ENDIF ()
89 90 91 92 93 94
    IF (CMAKE_DEPFILE_FLAGS_C)
        SET(CMAKE_DEPFILE_FLAGS_C "")
    ENDIF ()
    IF (CMAKE_DEPFILE_FLAGS_CXX)
        SET(CMAKE_DEPFILE_FLAGS_CXX "")
    ENDIF ()
wafwerar's avatar
wafwerar 已提交
95 96 97

    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}")
98 99

ELSE ()
haoranc's avatar
haoranc 已提交
100 101 102 103 104 105 106 107
    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(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
    ENDIF ()

S
Shengliang Guan 已提交
108
    IF (${BUILD_SANITIZER})
wafwerar's avatar
wafwerar 已提交
109 110
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}     -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3 -Wformat=0")
S
Shengliang Guan 已提交
111
	      MESSAGE(STATUS "Will compile with Address Sanitizer!")
112
    ELSE ()
wafwerar's avatar
wafwerar 已提交
113 114
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=0")
115 116 117
    ENDIF ()

    MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
wafwerar's avatar
wafwerar 已提交
118
    IF (TD_INTEL_64 OR TD_INTEL_32)
119 120 121 122 123 124 125
        ADD_DEFINITIONS("-msse4.2")
        IF("${FMA_SUPPORT}" MATCHES "true")
            MESSAGE(STATUS "turn fma function support on")
            ADD_DEFINITIONS("-mfma")
        ELSE ()
            MESSAGE(STATUS "turn fma function support off")
        ENDIF()
126
    ENDIF ()
127 128

ENDIF ()