Skip to content

Commit 2aafdf7

Browse files
committed
Fix dependency of the classic JDBC coneector on the MySQL client library or its dependencies
Note: This change also ensures that the openSSL library bundled with the server is used (if available) not the one that was found and used for building the XDevAPI connector.
1 parent 192c949 commit 2aafdf7

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

jdbc/CMakeLists.txt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -266,25 +266,12 @@ add_version_info(connector-jdbc
266266
"Implements MySQL Connector/C++ legacy JDBC API."
267267
)
268268

269+
# Note: The MySQL::client target works (and is needed) both when linking
270+
# to the MySQL client library dynamically and statically. In the latter case
271+
# it brings additional linker options that are required (e.g. to resolve
272+
# dependencies of the client library code).
269273

270-
271-
# Note: When connector links statically to the client library, targets using
272-
# the connector must be able to find dependencies of the client library, such
273-
# as openssl libs. The MYSQL_EXTERNAL_SEARCHPATH variable set by DepFindMySQL.
274-
# cmake stores detected locations where client library dependencies that
275-
# are bundled with it can be found. We add it here as interface property
276-
# so that other targets that link with the connector will have library search
277-
# path correctly set in the compile line.
278-
#
279-
# TODO: Modify merge_libraries() logic to autmatically detect transitive link
280-
# directory path properties of merged targets and then set them on the merged
281-
# library target.
282-
283-
if(MYSQLCLIENT_STATIC_LINKING)
284-
target_link_directories(connector-jdbc INTERFACE
285-
${MYSQL_EXTERNAL_SEARCHPATH}
286-
)
287-
endif()
274+
target_link_libraries(connector-jdbc PUBLIC MySQL::client)
288275

289276

290277
#

jdbc/cmake/DepFindMySQL.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ function(main)
297297

298298
if(MYSQL_LIB_STATIC)
299299
target_link_libraries(mysql-client-if INTERFACE MySQL::client-static)
300-
target_link_libraries(mysql-client-if INTERFACE OpenSSL::SSL)
301300
else()
302301
target_link_libraries(mysql-client-if INTERFACE MySQL::client-shared)
303302
endif()
@@ -379,7 +378,7 @@ function(main)
379378

380379
#
381380
# If external dependencies were found, add them to the static target
382-
# as any code that liks to static library should also link with the
381+
# as any code that links to static library should also link with the
383382
# external dependencies.
384383
#
385384

@@ -531,7 +530,8 @@ function(use_mysql_config)
531530
# option.
532531

533532
if(NOT lib MATCHES
534-
"(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic|^ssl|^crypto)"
533+
"(mysqlclient|libmysql|^stdc|^gcc|^CrunG3|^c$|^statomic)"
534+
#|^ssl|^crypto)"
535535
)
536536

537537
list(APPEND MYSQL_EXTERNAL_DEPENDENCIES ${lib})

jdbc/test/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ IF(MSBUILD)
7979
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS")
8080
ENDIF()
8181

82-
if(NOT MYSQLCLIENT_STATIC_LINKING)
83-
list(APPEND MY_TARGET_LINK_LIBRARIES MySQL::client)
84-
endif()
8582

8683
IF(CMAKE_COMPILER_IS_GNUCC AND MYSQLCPPCONN_GCOV_ENABLE)
8784
SET(MY_GCOV_LINK_LIBRARIES gcov)

0 commit comments

Comments
 (0)