forked from jbaldwin/libwingmysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
162 lines (139 loc) · 4.51 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required(VERSION 3.0.2)
project(wingmysql CXX)
# Create a Debug/lib or Release/lib output directory.
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/lib)
option(WING_PERCONA_SSL_DISABLED "Disable Percona MySQL SSL" OFF)
# Custom MySQL library/include locations.
if(NOT "$ENV{MYSQL_CLIENT_INCLUDE}" STREQUAL "")
set(MYSQL_CLIENT_INCLUDE $ENV{MYSQL_CLIENT_INCLUDE})
else()
set(MYSQL_CLIENT_INCLUDE "/usr/include/mysql" CACHE STRING "User specified mysql-client include location.")
endif()
if(NOT "$ENV{MYSQL_CLIENT_LIB}" STREQUAL "")
set(MYSQL_CLIENT_LIB $ENV{MYSQL_CLIENT_LIB})
else()
set(MYSQL_CLIENT_LIB "libmysqlclient_r.so" CACHE STRING "User specified mysql-client location.")
endif()
if(NOT "$ENV{SSL_INCLUDE}" STREQUAL "")
set(SSL_INCLUDE $ENV{SSL_INCLUDE})
else()
set(SSL_INCLUDE "" CACHE STRING "User specified ssl include location.")
endif()
if(NOT "$ENV{SSL_LIB}" STREQUAL "")
set(SSL_LIB $ENV{SSL_LIB})
else()
set(SSL_LIB "ssl" CACHE STRING "User specified libssl location.")
endif()
if(NOT "$ENV{}" STREQUAL "")
set(CRYPTO_LIB $ENV{CRYPTO_LIB})
else()
set(CRYPTO_LIB "crypto" CACHE STRING "User specified libcrypto location.")
endif()
option(D_GLIBCXX_DEBUG "Use D_GLIBCXX_DEBUG when building Debug" ON)
message("${PROJECT_NAME} MYSQL_CLIENT_INCLUDE = ${MYSQL_CLIENT_INCLUDE}")
message("${PROJECT_NAME} MYSQL_CLIENT_LIB = ${MYSQL_CLIENT_LIB}")
message("${PROJECT_NAME} SSL_INCLUDE = ${SSL_INCLUDE}")
message("${PROJECT_NAME} SSL_LIB = ${SSL_LIB}")
message("${PROJECT_NAME} CRYPTO_LIB = ${CRYPTO_LIB}")
message("${PROJECT_NAME} D_GLIBCXX_DEBUG=${D_GLIBCXX_DEBUG}")
# Set some general system dependencides.
set(WING_SYSTEM_LIBRARY_DEPENDENCIES
uv
pthread
m
rt
dl
z
)
set(WING_MYSQL_INCLUDE
${MYSQL_CLIENT_INCLUDE}
${SSL_INCLUDE}
)
set(WING_MYSQL_LIBRARY_DEPENDENCIES
${MYSQL_CLIENT_LIB}
${SSL_LIB}
${CRYPTO_LIB}
)
if (WING_PERCONA_SSL_DISABLED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWING_PERCONA_SSL_DISABLED")
ENDIF()
set(LIB_WING_MYSQL_SOURCE_FILES
inc/wing/ConnectionInfo.h src/ConnectionInfo.cpp
inc/wing/EventLoop.h src/EventLoop.cpp
inc/wing/Query.h src/Query.cpp
inc/wing/QueryHandle.h src/QueryHandle.cpp
inc/wing/QueryPool.h src/QueryPool.cpp
inc/wing/QueryStatus.h src/QueryStatus.cpp
inc/wing/Row.h src/Row.cpp
inc/wing/Statement.h inc/wing/Statement.tcc src/Statement.cpp
inc/wing/Util.h src/Util.cpp
inc/wing/Value.h src/Value.cpp
inc/wing/WingMySQL.h src/WingMySQL.cpp
)
add_library(${PROJECT_NAME} STATIC ${LIB_WING_MYSQL_SOURCE_FILES})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${WING_MYSQL_INCLUDE})
target_link_libraries(${PROJECT_NAME} PRIVATE
${WING_MYSQL_LIBRARY_DEPENDENCIES}
${WING_SYSTEM_LIBRARY_DEPENDENCIES}
)
target_compile_options(
${PROJECT_NAME} PRIVATE
-Wall
-Wextra
-Weffc++
-Werror
-Wpedantic
-pedantic-errors
-MD
)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
target_compile_options(
${PROJECT_NAME} PRIVATE
-Wno-unknown-pragmas
)
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
target_compile_options(
${PROJECT_NAME} PRIVATE
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-weak-vtables
-Wno-gnu-anonymous-struct
-Wno-nested-anon-types
-Wno-exit-time-destructors
-Wno-global-constructors
-Wno-error=deprecated-declarations
-Wno-disabled-macro-expansion
-Wno-covered-switch-default
-fcolor-diagnostics
-ferror-limit=128
)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message("${PROJECT_NAME} is building Debug")
target_compile_options(
${PROJECT_NAME} PRIVATE
-O0
-g
-gdwarf-2
)
if(D_GLIBCXX_DEBUG)
message("${PROJECT_NAME} D_GLIBCXX_DEBUG is ON")
target_compile_options(${PROJECT_NAME} PRIVATE -D_GLIBCXX_DEBUG)
else()
message("${PROJECT_NAME} D_GLIBCXX_DEBUG is OFF")
endif()
else() # "Release"
message("${PROJECT_NAME} is building Release")
target_compile_options(
${PROJECT_NAME} PRIVATE
-O2
-g
-gdwarf-2
)
endif()
include(examples/CMakeLists.txt)