CMakeLists.txt 2.3 KB
Newer Older
H
Hongze Cheng 已提交
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
H
hzcheng 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
PROJECT(TDengine)

SET(CMAKE_C_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON)

#
## generate debug version:
## mkdir debug; cd debug; cmake -DCMAKE_BUILD_TYPE=Debug ..
## generate release version:
## mkdir release; cd release; cmake -DCMAKE_BUILD_TYPE=Release ..
#

#set macro definitions
ADD_DEFINITIONS(-D_REENTRANT -D_M_X64 -D__USE_POSIX -D_LIBC_REENTRANT)

#set macro definitions according to os platform
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR UNIX)
  ADD_DEFINITIONS(-DLINUX -D_LINUX)
ENDIF ()

#set debug & release related options
H
Hongze Cheng 已提交
23
SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
H
hzcheng 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
SET(COMMON_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
SET(DEBUG_FLAGS "-O0 -DDEBUG")

#compiler debug options
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_FLAGS} ${DEBUG_FLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} ${DEBUG_FLAGS}")

SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMMON_FLAGS}")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS}")

MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})

IF (${CMAKE_BUILD_TYPE} MATCHES "Release")
  MESSAGE(STATUS "Build Release Version")
ELSE ()
  SET(CMAKE_BUILD_TYPE "Debug")
  MESSAGE(STATUS "Build Debug Version")
ENDIF ()

#set output directory
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin)
H
Hongze Cheng 已提交
46
SET(TESTS_OUTPUT_DIR ${PROJECT_BINARY_DIR}/test)
H
hzcheng 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

MESSAGE(STATUS "Project binary output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library output path: " ${LIBRARY_OUTPUT_PATH})

# check for x64 platform
IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
  MESSAGE(STATUS "Check targe platform x64, pass")
  ADD_SUBDIRECTORY(deps)
  ADD_SUBDIRECTORY(src)
ELSE ()
  MESSAGE(FATAL_ERROR "Check targe platform x86, not supported yet")
ENDIF ()

SET(MAKE_INSTALL_SH "${PROJECT_SOURCE_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "MESSAGE(\"make install script: ${MAKE_INSTALL_SH}\")")
INSTALL(CODE "execute_process(COMMAND chmod 777 ${MAKE_INSTALL_SH})")
INSTALL(CODE "execute_process(COMMAND ${MAKE_INSTALL_SH} ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})")