-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
120 lines (107 loc) · 4.62 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
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
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(taos-tools
LANGUAGES C
VERSION 0.1.0
)
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(PkgConfig REQUIRED)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(OS_INFO "Darwin")
ELSE()
find_package(ZLIB)
if (ZLIB_FOUND)
set(ZLIB_PKG zlib)
add_definitions(-DDEFLATE_CODEC)
include_directories(${ZLIB_INCLUDE_DIRS})
message("${Green} Enabled deflate codec ${ColourReset}")
else (ZLIB_FOUND)
set(ZLIB_PKG "")
set(ZLIB_LIBRARIES "")
message("${Red} Disabled deflate codec. zlib not found. ${ColourReset}")
endif (ZLIB_FOUND)
pkg_check_modules(SNAPPY snappy)
IF (SNAPPY_FOUND AND ZLIB_FOUND) # Snappy borrows crc32 from zlib
set(SNAPPY_PKG libsnappy)
add_definitions(-DSNAPPY_CODEC)
include_directories(${SNAPPY_INCLUDE_DIRS})
message("${Green} Enabled snappy codec ${ColourReset}")
ELSE ()
execute_process(COMMAND chmod 777 ${PROJECT_SOURCE_DIR}/packaging/tools/get_os.sh)
EXECUTE_PROCESS(COMMAND readlink /bin/sh OUTPUT_VARIABLE SHELL_LINK)
MESSAGE(STATUS "The shell is: " ${SHELL_LINK})
IF (${SHELL_LINK} MATCHES "dash")
EXECUTE_PROCESS(COMMAND ${PROJECT_SOURCE_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE OS_INFO)
ELSE ()
EXECUTE_PROCESS(COMMAND sh ${PROJECT_SOURCE_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE OS_INFO)
ENDIF()
MESSAGE("Current OS is " ${OS_INFO})
set(SNAPPY_PKG "")
set(SNAPPY_LIBRARIES "")
MESSAGE("")
IF (${OS_INFO} MATCHES "CentOS")
MESSAGE("${Yellow}libsnappy not found or zlib not found.")
MESSAGE("NOTE: The snappy package lacks pkg-config support on CentOS Linux even it is already installed.")
MESSAGE(" It leads cmake prompt \"libsnappy not found.\", but it will works well.")
MESSAGE(" Please refer to https://github.com/google/snappy/pull/86.")
MESSAGE("${ColourReset}")
ELSE ()
MESSAGE("${Red}libsnappy not found or zlib not found.")
MESSAGE("${ColourReset}")
ENDIF ()
ENDIf (SNAPPY_FOUND AND ZLIB_FOUND)
find_package(PkgConfig)
pkg_check_modules(LZMA liblzma)
if (LZMA_FOUND)
set(LZMA_PKG liblzma)
add_definitions(-DLZMA_CODEC)
include_directories(${LZMA_INCLUDE_DIRS})
link_directories(${LZMA_LIBRARY_DIRS})
message("${Green} Enabled lzma codec ${ColourReset}")
else (LZMA_FOUND)
set(LZMA_PKG "")
set(LZMA_LIBRARIES "")
message("${Red} Disabled lzma codec. liblzma not found.${ColourReset}")
endif (LZMA_FOUND)
# Jansson JSON library
pkg_check_modules(JANSSON jansson>=2.3)
IF (JANSSON_FOUND)
MESSAGE("${Green} jansson found ${ColourReset}")
include_directories(${JANSSON_INCLUDE_DIRS})
ELSE()
MESSAGE(FATAL_ERROR "${Red} jansson not found ${ColourReset}")
ENDIF()
ENDIF ()
ENDIF ()
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
IF (${VERBOSE} MATCHES "true")
SET(CMAKE_VERBOSE_MAKEFILE ON)
ENDIF ()
ADD_SUBDIRECTORY(deps)
ADD_SUBDIRECTORY(src)
ADD_DEPENDENCIES(taosBenchmark toolscJson)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(MAKE_INSTALL_SH "${PROJECT_SOURCE_DIR}/packaging/tools/make_install.sh")
INSTALL(CODE "execute_process(COMMAND bash ${MAKE_INSTALL_SH} ${CMAKE_BINARY_DIR})")
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
SET(MAKE_INSTALL_SH "${PROJECT_SOURCE_DIR}/packaging/tools/make_install.bat")
INSTALL(CODE "execute_process(COMMAND ${MAKE_INSTALL_SH} :needAdmin ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} Windows)")
ENDIF ()