Skip to content

Commit f9901f9

Browse files
committed
Merge with master branch.
2 parents 9de148e + 7f073c9 commit f9901f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2308
-3663
lines changed

CMakeLists.txt

Lines changed: 93 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
2525
CMAKE_POLICY(VERSION 2.8.12)
2626
cmake_policy(SET CMP0022 NEW)
27+
cmake_policy(SET CMP0023 OLD)
2728

2829
#
2930
# Prevent cmake from setting its default value of CMAKE_INSTALL_PREFIX
@@ -38,6 +39,10 @@ PROJECT(MySQL_CONCPP)
3839
message("Building on system: ${CMAKE_SYSTEM} (${CMAKE_SYSTEM_PROCESSOR})")
3940
message("Using cmake generator: ${CMAKE_GENERATOR}")
4041

42+
if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
43+
set(SUNOS ON CACHE INTERNAL "")
44+
endif()
45+
4146
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
4247
set(IS64BIT 1)
4348
message("Using 64bit generator")
@@ -59,11 +64,12 @@ if(WIN32)
5964
endif()
6065

6166

67+
68+
6269
include(version.cmake)
6370

6471
# Base name for the connector libraries.
6572

66-
#set(LIB_NAME_BASE "mysqlcppconn2")
6773
set(LIB_NAME_BASE "mysqlcppconn${CONCPP_VERSION_MAJOR}")
6874
set(JDBC_LIB_NAME_BASE "mysqlcppconn")
6975

@@ -82,14 +88,42 @@ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cdk/cmake)
8288

8389
include(libutils)
8490

85-
8691
#
8792
# Install settings
8893
# ================
8994
#
9095

9196
include(install_layout.cmake)
9297

98+
set(
99+
BUNDLE_DEPENDENCIES OFF CACHE BOOLEAN
100+
"If enabled, external libraries used by the connector, such as openSSL,
101+
will be installed together with the connector library"
102+
)
103+
104+
#
105+
# Default install location
106+
#
107+
108+
if(NOT CMAKE_INSTALL_PREFIX)
109+
110+
if(WIN32)
111+
112+
if(DEFINED ENV{HOMEPATH})
113+
file(TO_CMAKE_PATH "$ENV{HOMEDRIVE}$ENV{HOMEPATH}" install_home)
114+
else()
115+
set(install_home "C:/Program Files (x86)")
116+
endif()
117+
set(CMAKE_INSTALL_PREFIX "${install_home}/MySQL/MySQL Connector C++ ${CONCPP_PACKAGE_BASE_VERSION}")
118+
119+
else()
120+
121+
set(CMAKE_INSTALL_PREFIX "/usr/local/mysql/connector-c++-${CONCPP_PACKAGE_BASE_VERSION}")
122+
123+
endif()
124+
125+
endif()
126+
93127

94128
#
95129
# Compiler settings
@@ -206,6 +240,22 @@ include(gcov)
206240
#endforeach()
207241

208242

243+
#
244+
# Linker settings
245+
# ===============
246+
#
247+
248+
#
249+
# Produce rpath dependent libraries on MacOS
250+
# see: <https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html#//apple_ref/doc/uid/TP40008306-SW1>
251+
# and: <https://cmake.org/cmake/help/v3.0/prop_tgt/MACOSX_RPATH.html>
252+
#
253+
254+
if(APPLE)
255+
set(CMAKE_MACOSX_RPATH ON)
256+
endif()
257+
258+
209259
#
210260
# Main project and its dependencies
211261
# =================================
@@ -284,24 +334,11 @@ SET(WITH_CDK_DOC 0)
284334
OPTION(WITH_CDK_TESTS "cdk tests" OFF)
285335
set(WITH_PIC ${CMAKE_POSITION_INDEPENDENT_CODE})
286336

287-
288-
if(NOT DEFINED WITH_SSL)
289-
SET(WITH_SSL "bundled" CACHE STRING "")
290-
endif()
291-
292-
IF(WITH_SSL)
293-
IF(WITH_SSL STREQUAL "bundled")
294-
ADD_DEFINITIONS(-DWITH_SSL_YASSL)
295-
ENDIF()
296-
ADD_DEFINITIONS(-DWITH_SSL)
297-
ENDIF()
298-
299-
300-
301337
ADD_SUBDIRECTORY(cdk)
302338
INCLUDE_DIRECTORIES(${CDK_INCLUDE_DIR})
303339
INCLUDE_DIRECTORIES(cdk/parser)
304340

341+
305342
#
306343
# Unit tests framework
307344
#
@@ -399,6 +436,39 @@ if(MSVC)
399436
)
400437
endif()
401438

439+
#
440+
# Embed rpath information in the connector library.
441+
#
442+
443+
set_property(TARGET connector PROPERTY BUILD_WITH_INSTALL_RPATH ON)
444+
445+
# The $ORIGIN/@loader_path entry tells to look for dependent libraries in the
446+
# location where our connector library is stored.
447+
448+
if(APPLE)
449+
set_property(TARGET connector APPEND PROPERTY INSTALL_RPATH "@loader_path")
450+
elseif(NOT WIN32)
451+
set_property(TARGET connector APPEND PROPERTY INSTALL_RPATH "$ORIGIN")
452+
endif()
453+
454+
455+
if(0)
456+
#
457+
# Add command to show rpath information
458+
#
459+
460+
if(APPLE)
461+
set(list_rpath_cmd otool -l $<TARGET_FILE:libconcpp> "|" grep RPATH -A2)
462+
elseif(NOT WIN32)
463+
set(list_rpath_cmd objdump -x $<TARGET_FILE:libconcpp> "|" grep RPATH -A2)
464+
endif()
465+
466+
add_custom_command(TARGET libconcpp POST_BUILD
467+
COMMAND ${list_rpath_cmd}
468+
COMMENT "RPATH setting for: $<TARGET_FILE_NAME:mysqlcppconn>"
469+
)
470+
endif()
471+
402472

403473
#
404474
# Pick output library name
@@ -419,7 +489,6 @@ endif()
419489
# static runtime.
420490
#
421491

422-
423492
if(BUILD_STATIC)
424493

425494
set(LIB_NAME "${LIB_NAME_BASE}-static")
@@ -453,9 +522,6 @@ set_target_properties(connector PROPERTIES
453522
)
454523

455524

456-
message("Connector libraries will be installed at: ${INSTALL_LIB_DIR}")
457-
458-
459525
install(TARGETS connector
460526
CONFIGURATIONS Release RelWithDebInfo
461527
ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC}"
@@ -476,7 +542,6 @@ install(TARGETS connector
476542
# =====
477543
#
478544

479-
480545
remove_definitions(-DCONCPP_BUILD_STATIC)
481546
remove_definitions(-DCONCPP_BUILD_SHARED)
482547

@@ -551,14 +616,15 @@ endif()
551616

552617
#
553618
# Linking test
619+
# ------------
554620
#
555-
# This test compiles test application using internall installation of built
621+
# This test compiles test application using internal installation of built
556622
# connector. It is important to work with installed files because otherwise
557-
# cmake does its magic to resolve missing dependencies when buiding test code.
623+
# cmake does its magic to resolve missing dependencies when building test code.
558624
# We don't want this to happen to make sure that test code can be built with
559625
# connector library only, as we distribute it.
560626
#
561-
# Note: internall installation into <binary_dir>/install is done by directly
627+
# Note: internal installation into <binary_dir>/install is done by directly
562628
# executing cmake_install.cmake script which is generated by cmake.
563629
#
564630
# TODO: Also test dynamic linking (requires adopting test app project)
@@ -583,6 +649,7 @@ add_custom_target(link_test
583649
COMMAND ${CMAKE_COMMAND}
584650
-G "${CMAKE_GENERATOR}"
585651
-D WITH_CONCPP=${PROJECT_BINARY_DIR}/install
652+
-D WITH_SSL="${WITH_SSL}"
586653
-D BUILD_STATIC=${BUILD_STATIC}
587654
-D STATIC_MSVCRT=${STATIC_MSVCRT}
588655
${jdbc_options}
@@ -592,6 +659,7 @@ add_custom_target(link_test
592659
VERBATIM
593660
)
594661

662+
add_dependencies(link_test connector)
595663
if(WITH_JDBC)
596664
add_dependencies(link_test build_jdbc)
597665
endif()
@@ -609,26 +677,8 @@ add_test(NAME Link_test
609677
# ========================
610678
#
611679

612-
if(NOT CMAKE_INSTALL_PREFIX)
613-
614-
if(WIN32)
615-
616-
if(DEFINED ENV{HOMEPATH})
617-
string(REPLACE "\\" "/" install_prefix "$ENV{HOMEDRIVE}$ENV{HOMEPATH}")
618-
else()
619-
set(install_prefix "C:/Program Files (x86)")
620-
endif()
621-
set(CMAKE_INSTALL_PREFIX "${install_prefix}/MySQL/MySQL Connector C++ ${CONCPP_PACKAGE_BASE_VERSION}")
622-
623-
else()
624-
625-
set(CMAKE_INSTALL_PREFIX "/usr/local/mysql/connector-c++-${CONCPP_PACKAGE_BASE_VERSION}")
626-
627-
endif()
628-
629-
endif()
630-
631680
message("Install location: ${CMAKE_INSTALL_PREFIX}")
681+
message("Connector libraries will be installed at: ${INSTALL_LIB_DIR}")
632682

633683
option(WITH_PACKAGES "Configure for building binary/source packages" OFF)
634684
if(WITH_PACKAGES)

cdk/CMakeLists.txt

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323

2424

2525
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
26+
cmake_policy(VERSION 2.8.12)
27+
cmake_policy(SET CMP0022 NEW) # consistently use INTERFACE_LINK_LIBRARIES property
28+
cmake_policy(SET CMP0023 OLD)
2629

2730

2831
PROJECT(MySQLCDK)
2932

30-
cmake_policy(VERSION 2.8.12)
31-
cmake_policy(SET CMP0022 NEW) # consistently use INTERFACE_LINK_LIBRARIES property
3233

3334
#
3435
# Detect if we are configured as stand-alone project, or sub-project.
@@ -148,28 +149,12 @@ endif()
148149
# Add SSL
149150
#
150151

151-
if(NOT DEFINED WITH_SSL)
152-
SET(WITH_SSL "bundled" CACHE STRING "TODO: Document me!")
153-
endif()
154-
155152
message("WITH_SSL: ${WITH_SSL}")
156153

157-
IF(WITH_SSL)
158-
IF(WITH_SSL STREQUAL "bundled")
159-
ADD_DEFINITIONS(-DWITH_SSL_YASSL)
160-
if(CDK_BIG_ENDIAN)
161-
ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
162-
endif()
163-
ADD_SUBDIRECTORY(extra/yassl)
164-
ELSE()
165-
MESSAGE(WARNING "WITH_SSL option set to unrecognized value '${WITH_SSL}'"
166-
" - will be ignored. Currently the only value allowed is"
167-
" 'bundled', which uses the bundled YaSSL library to implement"
168-
" TLS connections.")
169-
ENDIF()
170-
ADD_DEFINITIONS(-DWITH_SSL)
171-
ENDIF()
172-
154+
include(ssl)
155+
MYSQL_CHECK_SSL(${CDK_BIG_ENDIAN})
156+
add_config(WITH_SSL)
157+
add_config(WITH_SSL_YASSL)
173158

174159
#
175160
# Enable C++11
@@ -305,6 +290,8 @@ IF(WIN32)
305290
# 4625 = copy ctor was implicitly deleted (*)
306291
# 4626 = copy assignment was implicitly deleted (*)
307292
# 4711 = function 'function' selected for inline expansion
293+
# 4520 = The class has multiple default constructors. The first constructor is
294+
# used.
308295
#
309296
# Note: 4512 is disabled because according to C++11 standard the situations
310297
# that triggers this warning should be handled automatically by the compiler
@@ -316,10 +303,12 @@ IF(WIN32)
316303
# Note (*): We use this a lot when inheriting from foundation::nocopy - this
317304
# is our C++ way to disable copy semantics.
318305
#
306+
#
307+
# Note: 4520 only present on Visual Studio 12
319308

320309
set(CMAKE_${LANG}_FLAGS
321310
"${CMAKE_${LANG}_FLAGS} /Wall /wd4512 /wd4127 /wd4100
322-
/wd4820 /wd4571 /wd4710 /wd4514 /wd4625 /wd4626 /wd4464 /wd4711"
311+
/wd4820 /wd4571 /wd4710 /wd4514 /wd4625 /wd4626 /wd4464 /wd4711 /wd4520"
323312
)
324313

325314
# Note: We disable warnings related to C++11 language because we want this

0 commit comments

Comments
 (0)