-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
534 lines (434 loc) · 19.5 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
# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018-Present MongoDB Inc.
#
# The MySQL Connector/ODBC is licensed under the terms of the GPLv2
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
# MySQL Connectors. There are special exceptions to the terms and
# conditions of the GPLv2 as it is applied to this software, see the
# FLOSS License Exception
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
#
# 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
##########################################################################
PROJECT(MySQL_Connector_ODBC)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
#------- compatibility with older cmake versions ------
#message("CMAKE_VERSION: ${CMAKE_VERSION}")
if(CMAKE_VERSION VERSION_LESS "3.0")
macro(add_compile_options)
add_definitions(${ARGV})
endmacro()
endif()
#-----------------------------------------------------
FIND_PACKAGE(Threads)
INCLUDE(version.cmake)
IF(NOT WIN32)
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(dlopen DLOPEN_IN_LIBC)
SET(DL_INCLUDES)
SET(DL_LFLAGS)
SET(DL_LIBS)
IF(NOT DLOPEN_IN_LIBC)
FIND_LIBRARY(DL_LIBS dl)
ENDIF(NOT DLOPEN_IN_LIBC)
IF(DLOPEN_IN_LIBC OR DL_LIBS)
ADD_DEFINITIONS(-DHAVE_LIBDL)
ENDIF()
ENDIF(NOT WIN32)
#Default is to build both drivers
IF(UNICODE OR NOT ANSI)
MESSAGE(STATUS "Configuring to build Unicode driver")
SET(IS_UNICODE_DRIVER 1)
SET(CONNECTOR_DRIVER_TYPE "Unicode")
SET(CONNECTOR_DRIVER_TYPE_LIST "Unicode")
SET(CONNECTOR_DRIVER_TYPES_SHORT "w")
SET(PACKAGE_DRIVER_TYPES_SUFFIX "")
ENDIF(UNICODE OR NOT ANSI)
IF(ANSI OR NOT UNICODE)
MESSAGE(STATUS "Configuring to build ANSI driver")
SET(IS_UNICODE_DRIVER ${IS_UNICODE_DRIVER} 0)
# We need space separated string
IF(UNICODE OR NOT ANSI)
SET(CONNECTOR_DRIVER_TYPE "${CONNECTOR_DRIVER_TYPE} ANSI")
ELSE(UNICODE OR NOT ANSI)
SET(CONNECTOR_DRIVER_TYPE "ANSI")
ENDIF(UNICODE OR NOT ANSI)
LIST(APPEND CONNECTOR_DRIVER_TYPE_LIST "ANSI")
SET(CONNECTOR_DRIVER_TYPES_SHORT ${CONNECTOR_DRIVER_TYPES_SHORT} "a")
SET(PACKAGE_DRIVER_TYPES_SUFFIX ${PACKAGE_DRIVER_TYPE_SUFFIX} "-ansi")
ENDIF(ANSI OR NOT UNICODE)
SET(EDIT_WARNING_MESSAGE "Please do not edit this file - it is generated by cmake. Edit its source file instead.")
LIST(LENGTH IS_UNICODE_DRIVER DRIVERS_COUNT)
IF(MYSQLCLIENT_STATIC_LINKING)
ADD_DEFINITIONS(-DMYSQLCLIENT_STATIC_LINKING)
ELSE()
# ---------------- Checks for mysql_sys
IF(WIN32)
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}" )
SET(SHAREDIR share)
ELSE()
SET(DEFAULT_MYSQL_HOME ${CMAKE_INSTALL_PREFIX})
SET(SHAREDIR ${DEFAULT_MYSQL_HOME}/${INSTALL_MYSQLSHAREDIR})
ENDIF()
SET(DEFAULT_BASEDIR "${DEFAULT_MYSQL_HOME}")
IF(INSTALL_MYSQLDATADIR MATCHES "^/.*")
SET(MYSQL_DATADIR ${INSTALL_MYSQLDATADIR} CACHE PATH "default MySQL data directory")
ELSE()
SET(MYSQL_DATADIR "${DEFAULT_MYSQL_HOME}/${INSTALL_MYSQLDATADIR}" CACHE PATH "default MySQL data directory")
ENDIF()
IF(INSTALL_MYSQLKEYRINGDIR MATCHES "^/.*")
SET(MYSQL_KEYRINGDIR ${INSTALL_MYSQLKEYRINGDIR} CACHE PATH "default MySQL keyring directory")
ELSE()
SET(MYSQL_KEYRINGDIR "${DEFAULT_MYSQL_HOME}/${INSTALL_MYSQLKEYRINGDIR}" CACHE PATH "default MySQL keyring directory")
ENDIF()
SET(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}")
SET(PLUGINDIR "${DEFAULT_MYSQL_HOME}/${INSTALL_PLUGINDIR}")
IF(SYSCONFDIR)
SET(DEFAULT_SYSCONFDIR "${SYSCONFDIR}")
ENDIF()
INCLUDE(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/character_sets.cmake)
# We need some extra FAIL_REGEX patterns
# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link.
MACRO (MY_CHECK_C_COMPILER_FLAG FLAG RESULT)
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
FAIL_REGEX "argument unused during compilation"
FAIL_REGEX "unsupported .*option"
FAIL_REGEX "unknown .*option"
FAIL_REGEX "unrecognized .*option"
FAIL_REGEX "ignoring unknown option"
FAIL_REGEX "[Ww]arning: [Oo]ption"
FAIL_REGEX "error: visibility"
FAIL_REGEX "warning: visibility"
)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO()
MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT)
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
FAIL_REGEX "argument unused during compilation"
FAIL_REGEX "unsupported .*option"
FAIL_REGEX "unknown .*option"
FAIL_REGEX "unrecognized .*option"
FAIL_REGEX "ignoring unknown option"
FAIL_REGEX "[Ww]arning: [Oo]ption"
FAIL_REGEX "error: visibility"
FAIL_REGEX "warning: visibility"
)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO()
INCLUDE(configure.cmake)
# Run platform tests
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_SOURCE_DIR}/include/sys/my_config.h)
ENDIF(MYSQLCLIENT_STATIC_LINKING)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/VersionInfo.h.cmake ${CMAKE_SOURCE_DIR}/VersionInfo.h @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/macosx/postflight.in ${CMAKE_SOURCE_DIR}/scripts/macosx/postflight @ONLY)
IF(WIN32)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Install.bat.cmake ${CMAKE_SOURCE_DIR}/Install.bat @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Uninstall.bat.cmake ${CMAKE_SOURCE_DIR}/Uninstall.bat @ONLY)
ENDIF(WIN32)
#SET(CMAKE_VERBOSE_MAKEFILE ON)
IF(NOT WIN32 AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(DISABLE_GUI 1)
ENDIF(NOT WIN32 AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
# Disable mysql client debug and PSI
ADD_DEFINITIONS(-DDBUG_OFF -DDISABLE_ALL_PSI)
#-------------- find mysql --------------------
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindMySQL.cmake)
#-----------------------------------------------------
# find the crypto & kerberos libraries that must be dynamically linked
# to the ODBC driver in order for the baked-in mongosql_auth plugin to work.
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindMongoCrypto.cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindMongoKerberos.cmake)
#-------------- unixodbc/iodbc/win -------------------
IF(WIN32)
SET(ODBCLIB odbc32)
IF (ODBCCP32_LIB)
SET(ODBCINSTLIB ${ODBCCP32_LIB})
ELSE (ODBCCP32_LIB)
SET(ODBCINSTLIB odbccp32)
ENDIF (ODBCCP32_LIB)
MESSAGE(STATUS "ODBC Installation Library: ${ODBCINSTLIB}")
ELSE(WIN32)
IF(WITH_UNIXODBC)
SET(ODBCLIB odbc)
SET(ODBCINSTLIB odbcinst)
ELSE(WITH_UNIXODBC)
IF(ODBCINST_LIB_DIR)
SET(ODBCLIB iODBC)
SET(ODBCINSTLIB iODBCinst)
ELSE(ODBCINST_LIB_DIR)
SET(ODBCLIB iodbc)
SET(ODBCINSTLIB iodbcinst)
ENDIF(ODBCINST_LIB_DIR)
ENDIF(WITH_UNIXODBC)
# FindODBC uses ODBCLIB and ODBCINSTLIB in some cases
INCLUDE(cmake/FindODBC.cmake)
IF(WITH_UNIXODBC)
TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/havelpcwstr.c
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES='${ODBC_INCLUDES} ${ODBC_INCLUDE_DIR}'")
MESSAGE(STATUS "Checking if LPCWSTR type is present - ${COMPILE_RESULT}")
IF(COMPILE_RESULT)
ADD_DEFINITIONS(-DHAVE_LPCWSTR)
ADD_DEFINITIONS(-DUSE_UNIXODBC)
ENDIF(COMPILE_RESULT)
ADD_DEFINITIONS(-DHAVE_SQLGETPRIVATEPROFILESTRINGW)
ELSE(WITH_UNIXODBC)
ADD_DEFINITIONS(-DHAVE_SQLGETPRIVATEPROFILESTRINGW)
#---- if it is not UnixODBC we assume iODBC -------
ADD_DEFINITIONS(-DUSE_IODBC)
ENDIF(WITH_UNIXODBC)
ENDIF(WIN32)
#-----------------------------------------------------
#-------- configuring paths to odbc heders for compatibility checks ---------
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlcolattrib1.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib1.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlcolattrib2.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib2.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlparamopt1.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlparamopt1.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlparamopt2.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlparamopt2.c @ONLY)
#-----------------------------------------------------
#------------------ check compatibility---------------
TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib1.c)
MESSAGE(STATUS "Checking if SQLColAttribute last arg is compatible with SQLLEN* - ${COMPILE_RESULT}")
IF(COMPILE_RESULT)
ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLLEN_PTR)
ELSE(COMPILE_RESULT)
TRY_COMPILE(COMPILE_RESULT1 ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib2.c)
MESSAGE(STATUS "Checking if SQLColAttribute last arg is compatible with SQLPOINTER - ${COMPILE_RESULT1}")
IF(COMPILE_RESULT1)
ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLPOINTER)
ELSE(COMPILE_RESULT1)
# By default using SQLLEN parameter
ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLLEN_PTR)
ENDIF(COMPILE_RESULT1)
ENDIF(COMPILE_RESULT)
TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlparamopt1.c)
MESSAGE(STATUS "Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLULEN - ${COMPILE_RESULT}")
IF(COMPILE_RESULT)
ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLULEN_PTR)
ELSE(COMPILE_RESULT)
TRY_COMPILE(COMPILE_RESULT1 ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlparamopt2.c)
MESSAGE(STATUS "Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLUINTEGER - ${COMPILE_RESULT1}")
IF(COMPILE_RESULT1)
ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLUINTEGER_PTR)
ELSE(COMPILE_RESULT1)
# SQLULEN is a default
MESSAGE(STATUS "Apparently odbc headers could not be found. 2nd and 3rd parameters assumed to be (*)SQLULEN by default")
ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLULEN_PTR)
ENDIF(COMPILE_RESULT1)
ENDIF(COMPILE_RESULT)
#-----------------------------------------------------
IF(NOT NO_THREADS)
MESSAGE(STATUS "Enabling threads support")
ADD_DEFINITIONS(-DTHREAD)
ENDIF(NOT NO_THREADS)
#------------ build options for windows --------------
set(MAINTAINER_MODE OFF CACHE BOOL "Build sources in maintainer mode")
mark_as_advanced(MAINTAINER_MODE)
IF(WIN32)
REMOVE_DEFINITIONS(-DUNICODE)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ADD_DEFINITIONS(-DENGLISH -D_USERDLL)
ADD_DEFINITIONS(-D_WIN32 -DWIN32 -D_WINDOWS -D__WIN__)
#Since 5.5.13 libmysql introduces dependency on Secur32.lib
FILE(STRINGS "${MYSQL_INCLUDE_DIR}\\mysql_version.h" mysql_version REGEX "^\#define[ \t]+MYSQL_VERSION_ID")
STRING(REGEX REPLACE "^\#define[ \t]+MYSQL_VERSION_ID[ \t]+([0-9]+)" "\\1" MYSQL_CLIENT_VERSION "${mysql_version}")
IF(MYSQL_CLIENT_VERSION GREATER 50512)
MESSAGE(STATUS "MySQL client lib(version ${MYSQL_CLIENT_VERSION}) requires Secure32.lib - TRUE")
SET(SECURE32_LIB Secur32)
ENDIF(MYSQL_CLIENT_VERSION GREATER 50512)
# edits for all config build flags
FOREACH(TYPE C CXX)
# makefiles use blank configuration
FOREACH(CFG "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
SET(NEW_FLAGS "${CMAKE_${TYPE}_FLAGS${CFG}}")
# fix up static libc flags
IF(STATIC_MSVCRT)
STRING(REPLACE "/MD" "/MT" NEW_FLAGS "${NEW_FLAGS}")
IF(CFG STREQUAL "_DEBUG")
SET(NEW_FLAGS "${NEW_FLAGS} /MTd")
ELSEIF()
SET(NEW_FLAGS "${NEW_FLAGS} /MT")
ENDIF()
ELSEIF()
STRING(REPLACE "/MT" "/MD" NEW_FLAGS "${NEW_FLAGS}")
IF(CFG STREQUAL "_DEBUG")
SET(NEW_FLAGS "${NEW_FLAGS} /MDd")
ELSEIF()
SET(NEW_FLAGS "${NEW_FLAGS} /MD")
ENDIF()
ENDIF()
# Add some additional help for debug builds
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
STRING(REPLACE "/Zi" "/ZI" NEW_FLAGS "${NEW_FLAGS}")
SET(NEW_FLAGS "${NEW_FLAGS} /RTC1 /RTCc")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
# *FORCE* to override whats already placed into the cache
SET(CMAKE_${TYPE}_FLAGS${CFG} "${NEW_FLAGS}" CACHE STRING
"CMAKE_${TYPE}_FLAGS${CFG} (overwritten for odbc)" FORCE)
ENDFOREACH(CFG)
ENDFOREACH(TYPE)
if(NOT MAINTAINER_MODE)
# TODO: instead fix code to not generate compile warnings
add_compile_options(/W1 /wd4133 /wd4047 /wd4313 /wd4197)
else()
# TODO: When code is fixed so that there are no warnings on this level,
# increase to /W2 and so on, until /Wall is reached. When /Wall is green on
# Windows, proceed to fixing remaining warnings on Unix builds.
add_compile_options(/W1)
endif()
ELSE(WIN32)
ADD_DEFINITIONS(-D_UNIX_)
if(NOT MAINTAINER_MODE)
# TODO: instead fix code to not generate compile warnings
add_compile_options( -w )
endif()
ENDIF(WIN32)
#-----------------------------------------------------
SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
SET(LIB_SUBDIR "lib")
IF(RPM_BUILD AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|ppc64|ppc64p7|s390x|sparc64)")
SET(LIB_SUBDIR "lib64")
ENDIF()
MESSAGE(STATUS "Installation library subdir: ${LIB_SUBDIR}")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(driver)
IF(NOT DISABLE_GUI)
ADD_SUBDIRECTORY(setupgui)
ENDIF(NOT DISABLE_GUI)
ADD_SUBDIRECTORY(dltest)
ADD_SUBDIRECTORY(installer)
ADD_SUBDIRECTORY(test)
# For dynamic linking use the built-in sys and strings
IF(NOT MYSQLCLIENT_STATIC_LINKING)
ADD_SUBDIRECTORY(mysql_sys)
ADD_SUBDIRECTORY(mysql_strings)
ENDIF()
##############################################################################
#
# Packaging
#
##############################################################################
# Some stuff for building RPMs, that is not using CPack
# RPMs doesn't allow "-" in version, so we use like "5.3.0_alpha"
STRING(REPLACE "-" "_" CONNECTOR_NODASH_VERSION "${CONNECTOR_VERSION}")
IF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE CURRENT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/myodbc3.spec.sh ${CMAKE_SOURCE_DIR}/myodbc3.spec @ONLY)
# The rest is mainly about CPack
SET(CPACK_PACKAGE_VERSION_MAJOR ${CONNECTOR_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${CONNECTOR_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${CONNECTOR_PATCH})
IF(NOT EXTRA_NAME_SUFFIX)
SET(EXTRA_NAME_SUFFIX "")
ENDIF(NOT EXTRA_NAME_SUFFIX)
IF(NOT EXTRA_NAME_SUFFIX2)
SET(EXTRA_NAME_SUFFIX2 "")
ENDIF(NOT EXTRA_NAME_SUFFIX2)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Connector/ODBC ${CONNECTOR_BASE_VERSION}, a library for connecting to MySQL servers.")
SET(CPACK_PACKAGE_NAME "mysql-connector-odbc${EXTRA_NAME_SUFFIX}")
IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
ELSE(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CONNECTOR_VERSION}-src")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CONNECTOR_VERSION}${EXTRA_NAME_SUFFIX2}${PACKAGE_DRIVER_TYPE_SUFFIX}-${CONNECTOR_PLATFORM}")
IF(WIN32)
SET(CPACK_GENERATOR "ZIP")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-noinstall-${CONNECTOR_VERSION}${EXTRA_NAME_SUFFIX2}${PACKAGE_DRIVER_TYPE_SUFFIX}-${CONNECTOR_PLATFORM}")
ELSE(WIN32)
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
ENDIF(WIN32)
SET(CPACK_SOURCE_IGNORE_FILES
\\\\.bzr/
\\\\.bzr-mysql
\\\\.bzrignore
CMakeCache\\\\.txt
CPackSourceConfig\\\\.cmake
CPackConfig\\\\.cmake
VersionInfo\\\\.h$
postflight$
/cmake_install\\\\.cmake
/CTestTestfile\\\\.cmake
/CMakeFiles/
/_CPack_Packages/
Makefile$
cmake/sql.*\\\\.c$
)
#------------ Installation ---------------------------
IF(WIN32)
# For conveninence copy (un)install.bat scripts to the build
# directory to ease testing.
CONFIGURE_FILE(Install.bat ${CMAKE_BINARY_DIR}/Install.bat COPYONLY)
CONFIGURE_FILE(Uninstall.bat ${CMAKE_BINARY_DIR}/Uninstall.bat COPYONLY)
# TODO: line-ending conversions unix->dos
INSTALL(FILES ChangeLog DESTINATION . RENAME ChangeLog.txt)
INSTALL(FILES README.md DESTINATION . RENAME README.md)
INSTALL(FILES README.debug DESTINATION . RENAME README.debug.txt)
INSTALL(FILES INSTALL DESTINATION . RENAME INSTALL.txt)
INSTALL(FILES INSTALL.win DESTINATION . RENAME INSTALL.win.txt)
IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
INSTALL(FILES COPYING DESTINATION . RENAME COPYING.txt)
ELSE()
INSTALL(FILES LICENSE.mysql DESTINATION . RENAME LICENSE.mysql.txt)
ENDIF()
INSTALL(FILES Install.bat DESTINATION .)
INSTALL(FILES Uninstall.bat DESTINATION .)
# Install all .pdb files to enable debugging. Note that what build
# type and what sub directory the binaries ends up in, like
# "Release" and "Debug", is not determined until we run "devenv" or
# similar. So when running "cmake" we don't know the location. We
# can't test for the location here, a IF(EXISTS ...) is run at
# "cmake" invocation time, not when we are to install. So we do a
# bit of a hack here until finding a better solution.
INSTALL(DIRECTORY
${PROJECT_BINARY_DIR}/bin/RelWithDebInfo/
${PROJECT_BINARY_DIR}/bin/Debug/
DESTINATION bin
FILES_MATCHING
PATTERN *.pdb
)
INSTALL(DIRECTORY
${PROJECT_BINARY_DIR}/lib/RelWithDebInfo/
${PROJECT_BINARY_DIR}/lib/Debug/
DESTINATION lib
FILES_MATCHING
PATTERN *.pdb
)
ELSE(WIN32)
INSTALL(FILES ChangeLog DESTINATION .)
INSTALL(FILES README DESTINATION .)
INSTALL(FILES README.debug DESTINATION .)
INSTALL(FILES INSTALL DESTINATION .)
IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
INSTALL(FILES COPYING DESTINATION .)
ELSE()
INSTALL(FILES LICENSE.mysql DESTINATION .)
ENDIF()
ENDIF(WIN32)
INSTALL(FILES Licenses_for_Third-Party_Components.txt DESTINATION .)
INCLUDE(CPack)