forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
317 lines (282 loc) · 9.34 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY
${SSL_DEFINES})
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libmysql
${CMAKE_SOURCE_DIR}/libbinlogevents/include
${CMAKE_SOURCE_DIR}/libmysqld
${CMAKE_SOURCE_DIR}/sql
${CMAKE_SOURCE_DIR}/sql/auth
${CMAKE_SOURCE_DIR}/sql/conn_handler
${CMAKE_BINARY_DIR}/libmysqld
${CMAKE_BINARY_DIR}/sql
${CMAKE_SOURCE_DIR}/regex
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${SSL_INTERNAL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/sql/backup
${LZ4_INCLUDE_DIR}
)
# We should generate these separately for libmysqld to avoid
# compiling them for libmysqld while they are generated for sql.
SET(GEN_YACC_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
)
SET(GEN_SOURCES
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
COMMAND gen_lex_hash > lex_hash.h
DEPENDS gen_lex_hash
)
SET_SOURCE_FILES_PROPERTIES(${GEN_YACC_SOURCES}
${GEN_SOURCES}
PROPERTIES GENERATED TRUE)
FOREACH(file ${SQL_EXPORTED_SOURCES})
LIST(APPEND IMPORTED_SOURCES "../sql/${file}")
ENDFOREACH()
SET(SQL_EMBEDDED_SOURCES
emb_qcache.cc
lib_sql.cc
libmysqld.c
${GEN_SOURCES}
${GEN_YACC_SOURCES}
../extra/lz4/xxhash.c
../client/get_password.c
../libmysql/errmsg.c
../libmysql/libmysql.c
../sql-common/client.c
../sql-common/client_plugin.c
../sql-common/my_time.c
../sql-common/my_user.c
../sql-common/pack.c
../sql-common/sql_string.cc
../libbinlogevents/src/statement_events.cpp
../libbinlogevents/src/control_events.cpp
../libbinlogevents/src/load_data_events.cpp
../libbinlogevents/src/rows_event.cpp
../libbinlogevents/src/binlog_event.cpp
../libbinlogevents/src/binary_log_funcs.cpp
../libbinlogevents/src/uuid.cpp
../sql/binlog.cc
../sql/event_parse_data.cc
../sql/log_event.cc
../sql/mysqld_thd_manager.cc
../sql/rpl_filter.cc
../sql/rpl_injector.cc
../sql/rpl_record.cc
../sql/rpl_reporting.cc
../sql/rpl_utility.cc
../sql/rpl_gtid_misc.cc
../sql/rpl_gtid_sid_map.cc
../sql/rpl_gtid_set.cc
../sql/rpl_gtid_specification.cc
../sql/rpl_gtid_state.cc
../sql/rpl_gtid_owned.cc
../sql/rpl_gtid_execution.cc
../sql/rpl_gtid_mutex_cond_array.cc
../sql/rpl_gtid_persist.cc
../sql/rpl_table_access.cc
../sql/rpl_context.cc
../sql/rpl_trx_boundary_parser.cc
${IMPORTED_SOURCES}
)
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
ADD_COMPILE_FLAGS(
../sql/debug_sync.cc
../sql/handler.cc
../sql/geometry_rtree.cc
../sql/item_geofunc.cc
../sql/item_geofunc_buffer.cc
../sql/item_geofunc_internal.cc
../sql/item_geofunc_relchecks.cc
../sql/item_geofunc_relchecks_bgwrap.cc
../sql/item_geofunc_setops.cc
../sql/item_json_func.cc
../sql/spatial.cc
COMPILE_FLAGS -I${BOOST_PATCHES_DIR} -I${BOOST_INCLUDE_DIR}
)
ADD_COMPILE_FLAGS(
../extra/lz4/xxhash.c
COMPILE_FLAGS -DXXH_NAMESPACE=MY_
)
# Fixes "C1128: number of sections exceeded object file format limit" in MSVC /MD
# The flag /bigobj is not added if the build is not /MD
IF(WIN32 AND CMAKE_SIZEOF_VOID_P MATCHES 8)
FOREACH(flag
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
STRING(FIND ${${flag}} "/MD" POS)
IF(NOT (${POS} MATCHES "-1"))
ADD_COMPILE_FLAGS(../sql/item_geofunc_setops.cc COMPILE_FLAGS "/bigobj")
BREAK()
ENDIF()
ENDFOREACH()
ENDIF()
# Boost source has unused local typedefs.
MY_CHECK_CXX_COMPILER_FLAG("-Wno-unused-local-typedefs" HAVE_NO_UNUSED_TYPEDEFS)
IF(HAVE_NO_UNUSED_TYPEDEFS)
ADD_COMPILE_FLAGS(
../sql/debug_sync.cc
../sql/handler.cc
../sql/geometry_rtree.cc
../sql/item_geofunc.cc
../sql/item_geofunc_buffer.cc
../sql/item_geofunc_internal.cc
../sql/item_geofunc_relchecks.cc
../sql/item_geofunc_relchecks_bgwrap.cc
../sql/item_geofunc_setops.cc
../sql/item_json_func.cc
../sql/spatial.cc
COMPILE_FLAGS "-Wno-unused-local-typedefs"
)
ENDIF()
# Boost source has misleading indentation
MY_CHECK_CXX_COMPILER_FLAG("-Wmisleading-indentation"
HAVE_MISLEADING_INDENTATION)
IF(HAVE_MISLEADING_INDENTATION)
ADD_COMPILE_FLAGS(
../sql/geometry_rtree.cc
../sql/item_geofunc.cc
../sql/item_geofunc_buffer.cc
../sql/item_geofunc_internal.cc
../sql/item_geofunc_relchecks.cc
../sql/item_geofunc_relchecks_bgwrap.cc
../sql/item_geofunc_setops.cc
COMPILE_FLAGS "-Wno-misleading-indentation")
ENDIF()
# Handle out-of-source build from source package with possibly broken
# bison. Copy bison output to from source to build directory, if not already
# there
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
COPY_BISON_OUTPUT(
${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
)
COPY_BISON_OUTPUT(
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy.cc
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy.h
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
)
RUN_BISON(
${CMAKE_SOURCE_DIR}/sql/sql_yacc.yy
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
MYSQL
)
RUN_BISON(
${CMAKE_SOURCE_DIR}/sql/sql_hints.yy
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.cc
${CMAKE_CURRENT_BINARY_DIR}/sql_hints.yy.h
HINT_PARSER_
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
COMMAND gen_lex_token > lex_token.h
DEPENDS gen_lex_token
)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_BINARY_DIR}/sql/lex_token.h
PROPERTIES GENERATED 1)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
${CMAKE_SOURCE_DIR}/sql/sql_digest.cc
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lex_token.h
)
ADD_CUSTOM_TARGET(GenYaccEmbeddedSource DEPENDS ${GEN_YACC_SOURCES})
ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
DTRACE_INSTRUMENT(sql_embedded)
ADD_DEPENDENCIES(sql_embedded GenError GenServerSource GenYaccEmbeddedSource)
# On Windows, static embedded server library is called mysqlserver.lib
# On Unix, it is libmysqld.a
IF(WIN32)
SET(MYSQLSERVER_OUTPUT_NAME mysqlserver)
ELSE()
SET(MYSQLSERVER_OUTPUT_NAME mysqld)
ENDIF()
SET(LIBS
dbug strings regex mysys mysys_ssl vio
${ZLIB_LIBRARY} ${SSL_LIBRARIES}
${LIBCRYPT} ${LIBDL}
${MYSQLD_STATIC_EMBEDDED_PLUGIN_LIBS}
sql_embedded
)
# Some storage engine were compiled for embedded specifically
# (with corresponding target ${engine}_embedded)
SET(EMBEDDED_LIBS)
FOREACH(LIB ${LIBS})
GET_TARGET_PROPERTY(EMBEDDED_LOCATION ${LIB}_embedded LOCATION)
IF(EMBEDDED_LOCATION)
LIST(APPEND EMBEDDED_LIBS ${LIB}_embedded)
ELSE()
LIST(APPEND EMBEDDED_LIBS ${LIB})
ENDIF()
ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME} COMPONENT Embedded)
# Visual Studio users need debug static library
IF(MSVC)
INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR}/debug)
ENDIF()
IF(UNIX)
INSTALL_DEBUG_TARGET(mysqlserver DESTINATION ${INSTALL_LIBDIR} RENAME
${CMAKE_STATIC_LIBRARY_PREFIX}mysqld-debug)
ENDIF()
IF(MSVC AND NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysqld SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS}
COMPONENT Embedded)
ENDIF()
OPTION(WITH_EMBEDDED_SHARED_LIBRARY
"Generate shared version of embedded library (in addition to the static one)"
OFF)
IF(WITH_EMBEDDED_SHARED_LIBRARY)
MERGE_LIBRARIES(libmysqld SHARED
mysqlserver
EXPORTS ${CLIENT_API_FUNCTIONS}
OUTPUT_NAME "mysqld"
COMPONENT Embedded)
SET_TARGET_PROPERTIES(libmysqld PROPERTIES
VERSION "${SHARED_LIB_MAJOR_VERSION}.${SHARED_LIB_MINOR_VERSION}.0"
SOVERSION "${SHARED_LIB_MAJOR_VERSION}"
)
GET_TARGET_PROPERTY(libmysqld_link_flags libmysqld LINK_FLAGS)
IF(NOT libmysqld_link_flag)
SET(libmysqld_link_flags)
ENDIF()
SET(libmysqld_link_flags
"${CMAKE_SHARED_LIBRARY_C_FLAGS} ${libmysqld_link_flags}")
SET_TARGET_PROPERTIES(libmysqld
PROPERTIES LINK_FLAGS "${libmysqld_link_flags}")
IF(LINK_FLAG_NO_UNDEFINED)
SET(libmysqld_link_flags
"${libmysqld_link_flags} ${LINK_FLAG_NO_UNDEFINED}")
SET_TARGET_PROPERTIES(libmysqld
PROPERTIES LINK_FLAGS "${libmysqld_link_flags}")
ENDIF()
SET_TARGET_PROPERTIES(libmysqld PROPERTIES CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(mysqlserver PROPERTIES CLEAN_DIRECT_OUTPUT 1)
ENDIF()