CMakeLists.txt 3.5 KB
Newer Older
S
Shengliang Guan 已提交
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
F
freemine 已提交
2 3
PROJECT(TDengine)

4 5 6 7 8 9 10 11 12 13 14 15
IF (TD_LINUX_64)
  find_program(HAVE_ODBCINST NAMES odbcinst)
  IF (HAVE_ODBCINST)
    include(CheckSymbolExists)
    # shall we revert CMAKE_REQUIRED_LIBRARIES and how?
    set(CMAKE_REQUIRED_LIBRARIES odbc)
    check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV)
    if(NOT (HAVE_ODBC_DEV))
      unset(HAVE_ODBC_DEV CACHE)
      message(WARNING "unixodbc-dev is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc-dev")
    else ()
      message(STATUS "unixodbc/unixodbc-dev are installed, and odbc connector will be built")
16 17
      find_package(FLEX)
      if(NOT FLEX_FOUND)
F
freemine 已提交
18
        message(WARNING "you need to install flex first")
19
      else ()
20 21 22
        if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0.0)
          message(WARNING "gcc 4.8.0 will complain too much about flex-generated code, we just bypass building ODBC driver in such case")
        else ()
23 24
          SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ")
          SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ")
25 26
          ADD_SUBDIRECTORY(src)
          ADD_SUBDIRECTORY(tools)
F
freemine 已提交
27
          ADD_SUBDIRECTORY(examples)
28
        endif ()
29
      endif()
30 31
    endif()
  ELSE ()
F
freemine 已提交
32
    message(WARNING "unixodbc is not installed yet, you may install it under ubuntu by typing: sudo apt install unixodbc")
33 34
  ENDIF ()
ENDIF ()
F
freemine 已提交
35

F
freemine 已提交
36 37 38 39 40 41 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
IF (TD_DARWIN)
  find_program(HAVE_ODBCINST NAMES odbcinst)
  IF (HAVE_ODBCINST)
    include(CheckSymbolExists)
    # shall we revert CMAKE_REQUIRED_LIBRARIES and how?
    set(CMAKE_REQUIRED_LIBRARIES odbc)
    set(CMAKE_REQUIRED_INCLUDES /usr/local/include)
    set(CMAKE_REQUIRED_LINK_OPTIONS -L/usr/local/lib)
    check_symbol_exists(SQLExecute "sql.h" HAVE_ODBC_DEV)
    if(NOT (HAVE_ODBC_DEV))
      unset(HAVE_ODBC_DEV CACHE)
      message(WARNING "unixodbc-dev is not installed yet, you may install it with homebrew by typing: brew install unixodbc")
    else ()
      message(STATUS "unixodbc/unixodbc-dev are installed, and odbc connector will be built")
      find_package(FLEX)
      if(NOT FLEX_FOUND)
        message(WARNING "you need to install flex first")
      else ()
        if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0.0)
          message(WARNING "gcc 4.8.0 will complain too much about flex-generated code, we just bypass building ODBC driver in such case")
        else ()
          SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wconversion")
          SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wconversion")
          ADD_SUBDIRECTORY(src)
          ADD_SUBDIRECTORY(tools)
          ADD_SUBDIRECTORY(examples)
        endif ()
      endif()
    endif()
  ELSE ()
    message(WARNING "unixodbc is not installed yet, you may install it under ubuntu by typing: brew install unixodbc")
  ENDIF ()
ENDIF ()

F
freemine 已提交
70
IF (TD_WINDOWS_64)
71 72
  find_package(ODBC)
  if (NOT ODBC_FOUND)
F
freemine 已提交
73
    message(WARNING "you need to install ODBC first")
74 75 76 77 78
  else ()
    message(STATUS "ODBC_INCLUDE_DIRS: ${ODBC_INCLUDE_DIRS}")
    message(STATUS "ODBC_LIBRARIES: ${ODBC_LIBRARIES}")
    message(STATUS "ODBC_CONFIG: ${ODBC_CONFIG}")
  endif ()
F
freemine 已提交
79 80
  find_package(FLEX)
  if(NOT FLEX_FOUND)
81 82 83
    message(WARNING "you need to install flex first\n"
                    "you may go to: https://github.com/lexxmark/winflexbison\n"
                    "or download from: https://github.com/lexxmark/winflexbison/releases")
F
freemine 已提交
84 85
  else ()
    ADD_SUBDIRECTORY(src)
86
    ADD_SUBDIRECTORY(tools)
F
freemine 已提交
87
    ADD_SUBDIRECTORY(examples)
F
freemine 已提交
88 89
  endif()
ENDIF ()
F
freemine 已提交
90