24
24
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12 )
25
25
CMAKE_POLICY (VERSION 2.8.12 )
26
26
cmake_policy (SET CMP0022 NEW )
27
+ cmake_policy (SET CMP0023 OLD )
27
28
28
29
#
29
30
# Prevent cmake from setting its default value of CMAKE_INSTALL_PREFIX
@@ -38,6 +39,10 @@ PROJECT(MySQL_CONCPP)
38
39
message ("Building on system: ${CMAKE_SYSTEM} (${CMAKE_SYSTEM_PROCESSOR} )" )
39
40
message ("Using cmake generator: ${CMAKE_GENERATOR} " )
40
41
42
+ if (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
43
+ set (SUNOS ON CACHE INTERNAL "" )
44
+ endif ()
45
+
41
46
if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
42
47
set (IS64BIT 1 )
43
48
message ("Using 64bit generator" )
@@ -59,11 +64,12 @@ if(WIN32)
59
64
endif ()
60
65
61
66
67
+
68
+
62
69
include (version .cmake )
63
70
64
71
# Base name for the connector libraries.
65
72
66
- #set(LIB_NAME_BASE "mysqlcppconn2")
67
73
set (LIB_NAME_BASE "mysqlcppconn${CONCPP_VERSION_MAJOR} " )
68
74
set (JDBC_LIB_NAME_BASE "mysqlcppconn" )
69
75
@@ -82,14 +88,42 @@ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cdk/cmake)
82
88
83
89
include (libutils )
84
90
85
-
86
91
#
87
92
# Install settings
88
93
# ================
89
94
#
90
95
91
96
include (install_layout.cmake )
92
97
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
+
93
127
94
128
#
95
129
# Compiler settings
@@ -206,6 +240,22 @@ include(gcov)
206
240
#endforeach()
207
241
208
242
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
+
209
259
#
210
260
# Main project and its dependencies
211
261
# =================================
@@ -284,24 +334,11 @@ SET(WITH_CDK_DOC 0)
284
334
OPTION (WITH_CDK_TESTS "cdk tests" OFF )
285
335
set (WITH_PIC ${CMAKE_POSITION_INDEPENDENT_CODE} )
286
336
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
-
301
337
ADD_SUBDIRECTORY (cdk )
302
338
INCLUDE_DIRECTORIES (${CDK_INCLUDE_DIR} )
303
339
INCLUDE_DIRECTORIES (cdk/parser )
304
340
341
+
305
342
#
306
343
# Unit tests framework
307
344
#
@@ -399,6 +436,39 @@ if(MSVC)
399
436
)
400
437
endif ()
401
438
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
+
402
472
403
473
#
404
474
# Pick output library name
@@ -419,7 +489,6 @@ endif()
419
489
# static runtime.
420
490
#
421
491
422
-
423
492
if (BUILD_STATIC )
424
493
425
494
set (LIB_NAME "${LIB_NAME_BASE} -static" )
@@ -453,9 +522,6 @@ set_target_properties(connector PROPERTIES
453
522
)
454
523
455
524
456
- message ("Connector libraries will be installed at: ${INSTALL_LIB_DIR} " )
457
-
458
-
459
525
install (TARGETS connector
460
526
CONFIGURATIONS Release RelWithDebInfo
461
527
ARCHIVE DESTINATION "${INSTALL_LIB_DIR_STATIC} "
@@ -476,7 +542,6 @@ install(TARGETS connector
476
542
# =====
477
543
#
478
544
479
-
480
545
remove_definitions (-DCONCPP_BUILD_STATIC )
481
546
remove_definitions (-DCONCPP_BUILD_SHARED )
482
547
@@ -551,14 +616,15 @@ endif()
551
616
552
617
#
553
618
# Linking test
619
+ # ------------
554
620
#
555
- # This test compiles test application using internall installation of built
621
+ # This test compiles test application using internal installation of built
556
622
# 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.
558
624
# We don't want this to happen to make sure that test code can be built with
559
625
# connector library only, as we distribute it.
560
626
#
561
- # Note: internall installation into <binary_dir>/install is done by directly
627
+ # Note: internal installation into <binary_dir>/install is done by directly
562
628
# executing cmake_install.cmake script which is generated by cmake.
563
629
#
564
630
# TODO: Also test dynamic linking (requires adopting test app project)
@@ -583,6 +649,7 @@ add_custom_target(link_test
583
649
COMMAND ${CMAKE_COMMAND}
584
650
-G "${CMAKE_GENERATOR} "
585
651
-D WITH_CONCPP=${PROJECT_BINARY_DIR}/install
652
+ -D WITH_SSL= "${WITH_SSL} "
586
653
-D BUILD_STATIC=${BUILD_STATIC}
587
654
-D STATIC_MSVCRT=${STATIC_MSVCRT}
588
655
${jdbc_options}
@@ -592,6 +659,7 @@ add_custom_target(link_test
592
659
VERBATIM
593
660
)
594
661
662
+ add_dependencies (link_test connector )
595
663
if (WITH_JDBC )
596
664
add_dependencies (link_test build_jdbc )
597
665
endif ()
@@ -609,26 +677,8 @@ add_test(NAME Link_test
609
677
# ========================
610
678
#
611
679
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
-
631
680
message ("Install location: ${CMAKE_INSTALL_PREFIX} " )
681
+ message ("Connector libraries will be installed at: ${INSTALL_LIB_DIR} " )
632
682
633
683
option (WITH_PACKAGES "Configure for building binary/source packages" OFF )
634
684
if (WITH_PACKAGES )
0 commit comments