forked from mariadb-corporation/mariadb-connector-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
590 lines (530 loc) · 23 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# ************************************************************************************
# Copyright (C) 2013,2019 MariaDB Corporation AB
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not see <http://www.gnu.org/licenses>
# or write to the Free Software Foundation, Inc.,
# 51 Franklin St., Fifth Floor, Boston, MA 02110, USA
# *************************************************************************************/
cmake_minimum_required(VERSION 3.1)
CMAKE_POLICY(SET CMP0048 NEW)
PROJECT(mariadb_connector_cpp
VERSION 0.9.4
# DESCRIPTION "MariaDB Connector/C++"
LANGUAGES CXX C)
SET(MACPP_VERSION_QUALITY "beta")
SET(MACPP_VERSION "0.09.0004")
SET(MARIADB_DEFAULT_PLUGINS_SUBDIR "plugin")
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(LIBRARY_NAME "mariadbcpp")
SET(CPACK_PACKAGE_NAME "${LIBRARY_NAME}")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/Version.h.in
${CMAKE_SOURCE_DIR}/src/Version.h)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/maconncpp.rc.in
${CMAKE_SOURCE_DIR}/src/maconncpp.rc)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/SearchLibrary.cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/SetValueMacro.cmake)
SET (MACPP_SOURCES src/MariaDbDriver.cpp
src/DriverManager.cpp
src/UrlParser.cpp
src/MariaDbDatabaseMetaData.cpp
src/HostAddress.cpp
src/Consts.cpp
src/SQLString.cpp
src/MariaDbConnection.cpp
src/MariaDbStatement.cpp
src/MariaDBException.cpp
src/MariaDBWarning.cpp
src/Identifier.cpp
src/MariaDbSavepoint.cpp
src/SqlStates.cpp
src/Results.cpp
src/ColumnType.cpp
src/ColumnDefinition.cpp
src/protocol/MasterProtocol.cpp
src/protocol/capi/QueryProtocol.cpp
src/protocol/capi/ConnectProtocol.cpp
src/com/capi/ColumnDefinitionCapi.cpp
src/cache/CallableStatementCache.cpp
src/cache/CallableStatementCacheKey.cpp
src/util/Value.cpp
src/util/Utils.cpp
src/util/String.cpp
src/logger/NoLogger.cpp
src/logger/LoggerFactory.cpp
src/logger/ProtocolLoggingProxy.cpp
src/parameters/ParameterHolder.cpp
src/options/Options.cpp
src/options/DefaultOptions.cpp
src/pool/GlobalStateInfo.cpp
src/pool/Pools.cpp
src/failover/FailoverProxy.cpp
src/credential/CredentialPluginLoader.cpp
src/SelectResultSet.cpp
src/com/capi/SelectResultSetCapi.cpp
#src/com/SelectResultSetPacket.cpp
#src/com/ColumnDefinitionPacket.cpp
src/com/ColumnNameMap.cpp
src/io/StandardPacketInputStream.cpp
src/Charset.cpp
#src/ClientSidePreparedStatement.cpp
src/BasePrepareStatement.cpp
src/MariaDbFunctionStatement.cpp
src/MariaDbProcedureStatement.cpp
src/ServerSidePreparedStatement.cpp
src/parameters/BigDecimalParameter.cpp
src/parameters/BooleanParameter.cpp
src/parameters/ByteArrayParameter.cpp
src/parameters/ByteParameter.cpp
src/parameters/DateParameter.cpp
src/parameters/DefaultParameter.cpp
src/parameters/DoubleParameter.cpp
src/parameters/FloatParameter.cpp
src/parameters/IntParameter.cpp
#src/parameters/LocalTimeParameter.cpp
src/parameters/LongParameter.cpp
src/parameters/ULongParameter.cpp
src/parameters/NullParameter.cpp
#src/parameters/OffsetTimeParameter.cpp
src/parameters/ParameterHolder.cpp
src/parameters/ReaderParameter.cpp
#src/parameters/SerializableParameter.cpp
src/parameters/ShortParameter.cpp
src/parameters/StreamParameter.cpp
src/parameters/TimeParameter.cpp
src/parameters/TimestampParameter.cpp
#src/parameters/ZonedDateTimeParameter.cpp
src/parameters/StringParameter.cpp
src/MariaDbPooledConnection.cpp
src/MariaDbParameterMetaData.cpp
src/MariaDbResultSetMetaData.cpp
src/CallParameter.cpp
src/CallableParameterMetaData.cpp
src/com/Packet.cpp
# src/util/ServerStatus.cpp # Won't be needed
# src/MariaDbServerCapabilities.cpp # Won't be needed
src/credential/Credential.cpp
src/util/LogQueryTool.cpp
src/util/ClientPrepareResult.cpp
src/util/ServerPrepareResult.cpp
src/util/ServerPrepareStatementCache.cpp
src/com/CmdInformationSingle.cpp
src/com/CmdInformationBatch.cpp
src/com/CmdInformationMultiple.cpp
src/com/RowProtocol.cpp
src/protocol/capi/BinRowProtocolCapi.cpp
src/protocol/capi/TextRowProtocolCapi.cpp
src/ExceptionFactory.cpp
src/StringImp.cpp
####CPP####
)
# Raw class implementations of classes we are not gonna use atm
# src/pool/Pool.cpp
IF(WIN32)
SET(MACPP_SOURCES ${MACPP_SOURCES}
src/Dll.c
src/MariaDBConnCpp.h
src/MariaDbDriver.h
src/UrlParser.h
src/MariaDbDatabaseMetaData.h
src/HostAddress.h
src/Version.h
src/Consts.h
src/MariaDbConnection.h
src/MariaDbStatement.h
src/MariaDBWarning.h
src/Protocol.h
src/Identifier.h
src/MariaDbSavepoint.h
src/SqlStates.h
src/Results.h
src/ColumnDefinition.h
src/MariaDbServerCapabilities.h
src/protocol/MasterProtocol.h
src/protocol/AbstractQueryProtocol.h
src/protocol/AbstractConnectProtocol.h
src/protocol/capi/QueryProtocol.h
src/protocol/capi/ConnectProtocol.h
src/com/capi/ColumnDefinitionCapi.h
src/cache/CallableStatementCache.h
src/cache/CallableStatementCacheKey.h
src/util/Value.h
src/util/ClassField.h
src/util/Utils.h
src/util/StateChange.h
src/util/String.h
src/logger/NoLogger.h
src/logger/LoggerFactory.h
src/logger/Logger.h
src/logger/ProtocolLoggingProxy.h
src/parameters/ParameterHolder.h
src/options/Options.h
src/options/DefaultOptions.h
src/options/DriverPropertyInfo.h
src/io/PacketOutputStream.h
src/io/PacketInputStream.h
src/io/StandardPacketInputStream.h
src/credential/CredentialPlugin.h
src/credential/CredentialPluginLoader.h
src/pool/GlobalStateInfo.h
src/pool/Pools.h
src/pool/Pool.h
src/failover/FailoverProxy.h
src/Listener.h
src/com/CmdInformation.h
"include/ConnCpp.h"
"include/Connection.h"
"include/Statement.h"
"include/ResultSet.h"
"include/PreparedStatement.h"
"include/ParameterMetaData.h"
"include/ResultSetMetaData.h"
"include/DatabaseMetaData.h"
"include/CallableStatement.h"
"include/SQLString.h"
"include/Warning.h"
"include/Exception.h"
"include/jdbccompat.h"
"include/Driver.h"
"include/DriverManager.h"
"include/Types.h"
src/SelectResultSet.h
src/com/capi/SelectResultSetCapi.h
src/com/SelectResultSetPacket.h
src/ColumnType.h
src/com/ColumnDefinitionPacket.h
src/com/ColumnNameMap.h
src/Charset.h
src/ClientSidePreparedStatement.h
src/BasePrepareStatement.h
src/MariaDbFunctionStatement.h
src/MariaDbProcedureStatement.h
src/ServerSidePreparedStatement.h
src/parameters/BigDecimalParameter.h
src/parameters/BooleanParameter.h
src/parameters/ByteArrayParameter.h
src/parameters/ByteParameter.h
src/parameters/DateParameter.h
src/parameters/DefaultParameter.h
src/parameters/DoubleParameter.h
src/parameters/FloatParameter.h
src/parameters/IntParameter.h
#src/parameters/LocalTimeParameter.h
src/parameters/LongParameter.h
src/parameters/ULongParameter.h
src/parameters/NullParameter.h
#src/parameters/OffsetTimeParameter.h
src/parameters/ReaderParameter.h
#src/parameters/SerializableParameter.h
src/parameters/ShortParameter.h
src/parameters/StreamParameter.h
src/parameters/TimeParameter.h
src/parameters/TimestampParameter.h
#src/parameters/ZonedDateTimeParameter.h
src/parameters/StringParameter.h
src/Parameters.h
src/MariaDbPooledConnection.h
src/MariaDbParameterMetaData.h
src/CallParameter.h
src/CallableParameterMetaData.h
src/MariaDbResultSetMetaData.h
src/com/Packet.h
src/util/ServerStatus.h
src/credential/Credential.h
src/util/LogQueryTool.h
src/util/ClientPrepareResult.h
src/util/ServerPrepareResult.h
src/util/ServerPrepareStatementCache.h
src/com/CmdInformationSingle.h
src/com/CmdInformationBatch.h
src/com/CmdInformationMultiple.h
src/com/RowProtocol.h
src/protocol/capi/BinRowProtocolCapi.h
src/protocol/capi/TextRowProtocolCapi.h
src/ExceptionFactory.h
src/StringImp.h
####H####
)
SOURCE_GROUP(Logging REGULAR_EXPRESSION "/logger/")
SOURCE_GROUP(PublicAPI REGULAR_EXPRESSION "include/")
SOURCE_GROUP(Parameters REGULAR_EXPRESSION "src/parameters")
SOURCE_GROUP(Options REGULAR_EXPRESSION "src/options")
SOURCE_GROUP(IO REGULAR_EXPRESSION "src/io")
SOURCE_GROUP(Credential REGULAR_EXPRESSION "src/credential")
SOURCE_GROUP(Pool REGULAR_EXPRESSION "src/pool")
SOURCE_GROUP(Utils REGULAR_EXPRESSION "src/util")
SOURCE_GROUP(Caches REGULAR_EXPRESSION "src/cache")
SOURCE_GROUP(Failover REGULAR_EXPRESSION "src/failover")
SOURCE_GROUP(Commands REGULAR_EXPRESSION "src/com/")
SOURCE_GROUP(Protocol REGULAR_EXPRESSION "src/protocol/")
SOURCE_GROUP(C_API REGULAR_EXPRESSION "/capi/")
SET(PLATFORM_DEPENDENCIES ws2_32)# Shlwapi)
ELSE()
SEARCH_LIBRARY(LIB_MATH floor m)
MESSAGE(STATUS "Found math lib: ${LIB_MATH}")
SET(PLATFORM_DEPENDENCIES ${LIB_MATH})
ENDIF()
MACRO(ADD_OPTION _name _text _default)
IF(NOT DEFINED ${_name})
OPTION(${OPT}${_name} "${_text}" "${_default}")
ELSE()
OPTION(${OPT}${_name} "${_text}" "${${_name}}")
ENDIF()
ENDMACRO()
# This has to be before C/C's cmake run, or it will build with /MD
IF(WIN32)
IF (MSVC)
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO" "MINSIZEREL")
FOREACH(BUILD_TYPE ${CONFIG_TYPES})
FOREACH(COMPILER CXX C)
SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
IF (NOT COMPILER_FLAGS STREQUAL "")
STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
IF (BUILD_TYPE STREQUAL "Debug")
SET(COMPILER_FLAGS "${COMPILER_FLAGS} /RTC1 /RTCc")
STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
ENDIF()
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE
STRING "overwritten by mariadb-cpp" FORCE)
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN)
ADD_DEFINITIONS("-DMARIADB_EXPORTED=__declspec(dllexport)")
SET(INSTALL_PLUGINDIR "${MARIADB_DEFAULT_PLUGINS_SUBDIR}")
ELSE()
# This has been done before C/C cmake scripts are included
IF(NOT DEFINED INSTALL_LIB_SUFFIX)
SET(INSTALL_LIB_SUFFIX "lib" CACHE STRING "Directory, under which to install libraries, e.g. lib or lib64")
IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND EXISTS "/usr/lib64/")
SET(INSTALL_LIB_SUFFIX "lib64")
ENDIF()
ENDIF()
MESSAGE(STATUS "Libraries installation dir: ${INSTALL_LIB_SUFFIX}")
# ADD_DEFINITIONS(-DMARIADB_EXPORTED)
MESSAGE(STATUS "Authentication Plugins installation dir: ${INSTALL_PLUGINDIR}")
ENDIF()
IF(WIN32 OR WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL")
IF(WITH_OPENSSL OR "${WITH_SSL}" STREQUAL "OPENSSL")
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
MESSAGE(STATUS "Configuring to build with OpenSSL ${OPENSSL_LIBRARIES}")
ADD_DEFINITIONS(-DHAVE_OPENSSL)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
#IF(OPENSSL_CRYPTO_LIBRARIES)
# SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
#ENDIF()
SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} ${SSL_LIBRARIES})
ELSE()
MESSAGE(FATAL_ERROR "OpenSSL not found. Please install OpenSSL or disable SSL support via option -DWITH_OPENSSL=Off")
ENDIF()
ELSE()
MESSAGE(STATUS "Configuring SSL support using SChannel")
SET(PLATFORM_DEPENDENCIES ${PLATFORM_DEPENDENCIES} version.lib)
ENDIF()
ELSE()
MESSAGE(STATUS "Configuring to build without SSL support")
ENDIF()
### Setting installation paths - should go before C/C subproject sets its own. We need to have control over those
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")
### Including C/C subproject
IF(EXISTS ${CMAKE_SOURCE_DIR}/libmariadb)
IF(GIT_BUILD_SRCPKG)
# We don't want conn/c (wrong) src pkg to be built.
SET(GIT_BUILD_SRCPKG FALSE)
SET(CONNCPP_GIT_BUILD_SRCPKG TRUE)
ENDIF()
MESSAGE(STATUS "Running C/C cmake scripts")
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/connector_c.cmake)
INSTALL(FILES
$<TARGET_FILE:libmariadb>
DESTINATION ./${INSTALL_LIB_SUFFIX}/mariadb
COMPONENT ConCLib)
ELSE()
SET(USE_SYSTEM_INSTALLED_LIB TRUE)
MESSAGE(STATUS "There is no Connector/C sub-project folder, linking against libmariadb installed on the system")
ENDIF()
IF(WIN32)
#ADD_OPTION(WITH_MSI "Build MSI installation package" OFF)
ADD_OPTION(WITH_SIGNCODE "Digitally sign files" OFF)
ENDIF()
IF(WITH_SIGNCODE)
IF(WIN32 AND NOT SIGN_OPTIONS)
SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll)
ELSE()
SEPARATE_ARGUMENTS(SIGN_OPTIONS)
ENDIF()
MARK_AS_ADVANCED(SIGN_OPTIONS)
ENDIF()
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/libmariadb/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/libmariadb/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
ENDIF()
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/maconncpp.def.in
${CMAKE_SOURCE_DIR}/src/maconncpp.def)
# Dynamic linking is default on non-Windows
IF(MARIADB_LINK_DYNAMIC OR NOT WIN32)# OR USE_SYSTEM_INSTALLED_LIB)
IF(USE_SYSTEM_INSTALLED_LIB)
SET(MARIADB_CLIENT_TARGET_NAME mariadb)
ELSE()
SET(MARIADB_CLIENT_TARGET_NAME libmariadb)
ENDIF()
MESSAGE(STATUS "Linking Connector/C library dynamically(${MARIADB_CLIENT_TARGET_NAME})")
ELSE()
SET(MARIADB_CLIENT_TARGET_NAME mariadbclient)
MESSAGE(STATUS "Linking Connector/C library statically(${MARIADB_CLIENT_TARGET_NAME})")
ENDIF()
IF(WIN32)
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${MACPP_SOURCES} ${CMAKE_SOURCE_DIR}/src/maconncpp.def ${CMAKE_SOURCE_DIR}/src/maconncpp.rc)
ELSE()
# MESSAGE(STATUS "Version script: ${CMAKE_SOURCE_DIR}/src/maconncpp.def")
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${MACPP_SOURCES})
IF(APPLE)
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-Wl")
ELSE()
# SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/maconncpp.def")
ENDIF()
ENDIF()
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${MARIADB_CLIENT_TARGET_NAME} ${PLATFORM_DEPENDENCIES})
########## Packaging ##########
# MSI
IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -DDRIVER_LIB_DIR=$<TARGET_FILE_DIR:${LIBRARY_NAME}>
-DPLUGINS_LIB_DIR=$<TARGET_FILE_DIR:dialog>
-DPLUGINS_SUBDIR_NAME=${MARIADB_DEFAULT_PLUGINS_SUBDIR}
-DFILE_IN=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml.in
-DFILE_OUT=${CMAKE_SOURCE_DIR}/wininstall/binaries_dir.xml
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureFile.cmake
)
ADD_SUBDIRECTORY(wininstall)
ELSE()
IF(APPLE)
#MESSAGE(STATUS "Configuring to generate PKG package")
#ADD_SUBDIRECTORY(osxinstall)
ENDIF()
INSTALL(TARGETS
${LIBRARY_NAME}
LIBRARY DESTINATION ./${INSTALL_LIB_SUFFIX}/mariadb
COMPONENT CppLibs)
MESSAGE(STATUS "Documentation installed to ${INSTALL_DOCDIR}")
MESSAGE(STATUS "License file installed to ${INSTALL_LICENSEDIR}")
MESSAGE(STATUS "Public API header files installed to ${INSTALL_INCLUDEDIR}")
INSTALL(FILES
${CMAKE_SOURCE_DIR}/README
DESTINATION
${INSTALL_DOCDIR}
COMPONENT Documentation)
INSTALL(FILES
${CMAKE_SOURCE_DIR}/COPYING
DESTINATION
${INSTALL_LICENSEDIR}
COMPONENT Documentation)
ADD_SUBDIRECTORY(include)
ENDIF()
# Tests. Checking if we have them. May be not the case if we are building from source package
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
ADD_SUBDIRECTORY(test)
ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy $<TARGET_FILE:${LIBRARY_NAME}> test)
ADD_CUSTOM_COMMAND(TARGET ${LIBRARY_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy $<TARGET_FILE:libmariadb> test)
ENDIF()
# Packaging
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
SET(CPACK_COMPONENTS_ALL ClientPlugins CppLibs ConCLib Documentation PublicAPI)
SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C++. C++ driver library for connecting to MariaDB and MySQL servers")
IF(NOT SYSTEM_NAME)
STRING(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
ENDIF()
IF(PACKAGE_PLATFORM_SUFFIX)
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-cpp-${CPACK_PACKAGE_VERSION}-${MACPP_VERSION_QUALITY}-${PACKAGE_PLATFORM_SUFFIX}")
ELSE()
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-cpp-${CPACK_PACKAGE_VERSION}-${MACPP_VERSION_QUALITY}-${SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
ENDIF()
MESSAGE(STATUS "Package Name: ${CPACK_PACKAGE_FILE_NAME}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_PACKAGE_API_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-cpp-${CPACK_PACKAGE_VERSION}-${MACPP_VERSION_QUALITY}-src")
SET(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation AB")
SET(CPACK_SOURCE_IGNORE_FILES
/test/
/.git/
.gitignore
.gitmodules
.gitattributes
CMakeCache.txt
cmake_dist.cmake
CPackSourceConfig.cmake
CPackConfig.cmake
/.build/
cmake_install.cmake
CTestTestfile.cmake
/CMakeFiles/
/version_resources/
.*vcxproj
.*gz$
.*zip$
.*so$
.*so.2
.*so.3
.*dll$
.*a$
.*pdb$
.*sln$
.*sdf$
install_manifest_*txt
Makefile$
tests_config.h
/autom4te.cache/
/.travis/
.travis.yml
/libmariadb/
/_CPack_Packages/
)
# Build source packages
IF(GIT_BUILD_SRCPKG OR CONNCPP_GIT_BUILD_SRCPKG)
IF(WIN32)
EXECUTE_PROCESS(COMMAND git archive --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip --worktree-attributes -v HEAD)
ELSE()
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip -v HEAD)
EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar -v HEAD)
EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
ENDIF()
ENDIF()
IF(WIN32)
SET(DEFAULT_GENERATOR "ZIP")
ELSE()
SET(DEFAULT_GENERATOR "TGZ")
ENDIF()
IF(NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR "${DEFAULT_GENERATOR}")
ENDIF()
IF(NOT CPACK_SOURCE_GENERATOR)
SET(CPACK_SOURCE_GENERATOR "${DEFAULT_GENERATOR}")
ENDIF()
MESSAGE(STATUS "License File: ${CPACK_RESOURCE_FILE_LICENSE}")
MESSAGE(STATUS "ReadMe File: ${CPACK_PACKAGE_DESCRIPTION_FILE}")
MESSAGE(STATUS "Source Package Filename: ${CPACK_SOURCE_PACKAGE_FILE_NAME}.${CPACK_SOURCE_GENERATOR}")
INCLUDE(CPack)