CMakeLists.txt 6.2 KB
Newer Older
H
Hongze Cheng 已提交
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
H
hzcheng 已提交
2 3 4 5
PROJECT(TDengine)

SET(CMAKE_C_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON)
S
slguan 已提交
6
SET(TD_ROOT_DIR ${PROJECT_SOURCE_DIR})
H
hzcheng 已提交
7 8

#
S
slguan 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# If it is a Linux operating system
#   1.Generate debug version:
#     mkdir debug; cd debug; 
#     cmake -DCMAKE_BUILD_TYPE=Debug ..
#   2.Generate release version:
#     mkdir release; cd release; 
#     cmake -DCMAKE_BUILD_TYPE=Release .. 
# If it is a Windows operating system
#   1.Use command line tool of VS2013 or higher version
#     mkdir build; cd build;
#     cmake -G "NMake Makefiles" ..
#     nmake install
#   2.Use the VS development interface tool 
#     mkdir build; cd build;
#     cmake -A x64 ..
#     open the file named TDengine.sln
H
hzcheng 已提交
25 26
#

S
slguan 已提交
27
# Set macro definitions according to os platform
S
slguan 已提交
28 29 30 31
SET(TD_WINDOWS FALSE)
SET(TD_LINUX FALSE)
SET(TD_ARM FALSE)
SET(TD_DARWIN FALSE)
H
hzcheng 已提交
32

33
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
S
slguan 已提交
34 35 36 37
  
  SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/linux)
  SET(TD_LINUX TRUE)
  ADD_DEFINITIONS(-DLINUX)
S
slguan 已提交
38

HowkWolf's avatar
HowkWolf 已提交
39 40 41 42 43
  IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")			
	SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
  ELSE ()
	SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
  ENDIF ()
S
slguan 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
  SET(DEBUG_FLAGS "-O0 -DDEBUG")
  SET(RELEASE_FLAGS "-O0")
  
  ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
  
  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    MESSAGE(STATUS "The current platform is Linux 64-bit")
    ADD_DEFINITIONS(-D_M_X64)
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet")
    EXIT ()
  ENDIF ()
  
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
  SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE)
  SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/windows)
  SET(TD_WINDOWS TRUE)
  ADD_DEFINITIONS(-DWINDOWS)
S
slguan 已提交
62 63 64
  ADD_DEFINITIONS(-D__CLEANUP_C)
  ADD_DEFINITIONS(-DPTW32_STATIC_LIB)
  ADD_DEFINITIONS(-DPTW32_BUILD)
S
slguan 已提交
65
  
S
slguan 已提交
66
  SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-")
S
slguan 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79
  SET(DEBUG_FLAGS "/Zi /W3 /GL")
  SET(RELEASE_FLAGS "/W0 /GL")	
  
  ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)  
  
  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    MESSAGE(STATUS "The current platform is Windows 64-bit")
    ADD_DEFINITIONS(-D_M_X64)    
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Windows 32-bit, not supported yet")
    EXIT ()
  ENDIF ()

S
slguan 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

  SET(TD_OS_DIR ${PROJECT_SOURCE_DIR}/src/os/darwin)
  SET(TD_DARWIN TRUE)
  ADD_DEFINITIONS(-DDARWIN)

  SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion")
  SET(DEBUG_FLAGS "-O0 -DDEBUG")
  SET(RELEASE_FLAGS "-O0")

  ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)

  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    MESSAGE(STATUS "The current platform is Darwin 64-bit")
    ADD_DEFINITIONS(-D_M_X64)
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
    EXIT ()
  ENDIF ()
S
slguan 已提交
99

S
slguan 已提交
100 101
ELSE ()
  MESSAGE(FATAL_ERROR "The current platform is not Linux/MAC/Windows, stop compile")
102
  EXIT ()
S
slguan 已提交
103
  
H
hzcheng 已提交
104 105
ENDIF ()

S
slguan 已提交
106
# Set compiler options
H
hzcheng 已提交
107
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}")
S
slguan 已提交
108
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS} ${RELEASE_FLAGS}")
H
hzcheng 已提交
109

S
slguan 已提交
110 111 112 113
# Set c++ compiler options
# SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
# SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")
# SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} ${RELEASE_FLAGS}")
H
hzcheng 已提交
114

S
slguan 已提交
115 116 117
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
  MESSAGE(STATUS "Build Debug Version")
ELSEIF (${CMAKE_BUILD_TYPE} MATCHES "Release")
H
hzcheng 已提交
118 119
  MESSAGE(STATUS "Build Release Version")
ELSE ()
S
slguan 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133
  IF (TD_WINDOWS)
    SET(CMAKE_BUILD_TYPE "Release")
	MESSAGE(STATUS "Build Release Version")
  ELSE ()
    SET(CMAKE_BUILD_TYPE "Debug")
	MESSAGE(STATUS "Build Debug Version")
  ENDIF()    
ENDIF ()

FIND_PROGRAM(TD_MVN_INSTALLED mvn)
IF (TD_MVN_INSTALLED)
  MESSAGE(STATUS "MVN is installed and JDBC will be compiled")
ELSE ()
  MESSAGE(STATUS "MVN is not installed and JDBC is not compiled")
H
hzcheng 已提交
134 135 136 137 138
ENDIF ()

#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
S
slguan 已提交
139 140 141 142 143 144 145
SET(TD_TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)

MESSAGE(STATUS "Operating system dependency directory: " ${TD_OS_DIR})
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})
H
hzcheng 已提交
146

S
slguan 已提交
147 148
ADD_SUBDIRECTORY(deps)
ADD_SUBDIRECTORY(src)
S
slguan 已提交
149
ADD_SUBDIRECTORY(tests)
H
hzcheng 已提交
150

S
slguan 已提交
151 152 153 154 155 156 157 158 159 160 161 162 163
IF (TD_LINUX)
  SET(TD_MAKE_INSTALL_SH "${TD_ROOT_DIR}/packaging/tools/make_install.sh")
  INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")")
  INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})")
  INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_ROOT_DIR} ${PROJECT_BINARY_DIR})")
ELSEIF (TD_WINDOWS)
  SET(CMAKE_INSTALL_PREFIX C:/TDengine)
  INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/go DESTINATION connector)
  INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/grafana DESTINATION connector)
  INSTALL(DIRECTORY ${TD_ROOT_DIR}/src/connector/python DESTINATION connector)
  INSTALL(DIRECTORY ${TD_ROOT_DIR}/tests/examples DESTINATION .)
  INSTALL(DIRECTORY ${TD_ROOT_DIR}/packaging/cfg DESTINATION .)
  INSTALL(FILES ${TD_ROOT_DIR}/src/inc/taos.h DESTINATION include)
S
slguan 已提交
164 165
  INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.lib DESTINATION driver)
  INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos.exp DESTINATION driver)
S
slguan 已提交
166 167 168
  INSTALL(TARGETS taos RUNTIME DESTINATION driver) 
  INSTALL(TARGETS shell RUNTIME DESTINATION .)
  IF (TD_MVN_INSTALLED)
169
      INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-1.0.2-dist.jar DESTINATION connector/jdbc)
S
slguan 已提交
170 171
  ENDIF ()
ENDIF ()  
H
hzcheng 已提交
172

S
slguan 已提交
173
INCLUDE(CPack)