@@ -156,26 +156,6 @@ endif()
156
156
# ========================================================================
157
157
# Dependencies
158
158
159
-
160
- if (NOT OPENSSL_FOUND )
161
- if (NOT WITH_SSL MATCHES "^(system|yes)$" )
162
-
163
- if (EXISTS ${WITH_SSL} /include/openssl/ssl.h )
164
- set (OPENSSL_ROOT_DIR "${WITH_SSL} " )
165
- endif ()
166
-
167
- endif ()
168
-
169
- find_package (OpenSSL )
170
-
171
- if (OPENSSL_FOUND )
172
- MESSAGE (STATUS "OPENSSL_VERSION = ${OPENSSL_VERSION} " )
173
- MESSAGE (STATUS "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY} " )
174
- MESSAGE (STATUS "OPENSSL_CRYPTO_LIBRARY = ${OPENSSL_CRYPTO_LIBRARY} " )
175
- endif ()
176
-
177
- endif ()
178
-
179
159
#
180
160
# Find Connector/C++ legacy library
181
161
#
@@ -284,34 +264,63 @@ set_target_properties(MySQL::conncpp-jdbc PROPERTIES
284
264
285
265
286
266
#
287
- # We need to link with libraries on which connector depends
288
- # (however, no need to do it on Windows).
267
+ # When linking statically, we need to link with libraries on which
268
+ # connector depends (however, no need to do it on Windows).
289
269
#
290
270
291
- if (NOT WIN32 )
271
+ if (BUILD_STATIC AND NOT WIN32 )
292
272
293
- # Connector/C++ requires these libraries on Unix.
273
+ set ( libs )
294
274
295
- if (NOT APPLE )
296
- set_property (TARGET MySQL::conncpp-jdbc
297
- APPEND PROPERTY INTERFACE_LINK_LIBRARIES pthread dl rt
298
- )
299
- endif ()
275
+ # Connector/C++ requires these libraries on Unix.
300
276
301
- # On Solaris we additionally need couple more libs.
277
+ if (NOT APPLE )
278
+ list (APPEND libs pthread dl rt )
279
+ endif ()
302
280
303
- if (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
304
- set_property (TARGET MySQL::conncpp-jdbc
305
- APPEND PROPERTY INTERFACE_LINK_LIBRARIES socket nsl
306
- )
307
- endif ()
281
+ # On Solaris we additionally need couple more libs.
282
+
283
+ if (CMAKE_SYSTEM_NAME MATCHES "SunOS" )
284
+ list (APPEND libs socket nsl )
285
+ endif ()
286
+
287
+ if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
288
+ list (APPEND libs execinfo unwind )
289
+ else ()
290
+ list (APPEND libs resolv )
291
+ endif ()
292
+
293
+ # OpenSSL dependency
294
+
295
+ if (WITH_SSL MATCHES "^(system|yes)$" )
296
+
297
+ list (APPEND libs ssl crypto )
298
+
299
+ else ()
300
+
301
+ if (NOT OPENSSL_FOUND )
302
+
303
+ if (EXISTS ${WITH_SSL} /include/openssl/ssl.h )
304
+ set (OPENSSL_ROOT_DIR "${WITH_SSL} " )
305
+ endif ()
306
+
307
+ find_package (OpenSSL REQUIRED )
308
+
309
+ MESSAGE (STATUS "OPENSSL_VERSION = ${OPENSSL_VERSION} " )
310
+ MESSAGE (STATUS "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY} " )
311
+ MESSAGE (STATUS "OPENSSL_CRYPTO_LIBRARY = ${OPENSSL_CRYPTO_LIBRARY} " )
308
312
309
- if (OPENSSL_FOUND )
310
- set_property (TARGET MySQL::conncpp-jdbc
311
- APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}
312
- )
313
313
endif ()
314
314
315
+ list (APPEND libs ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} )
316
+
317
+ endif ()
318
+
319
+ set_property (TARGET MySQL::conncpp-jdbc
320
+ APPEND PROPERTY INTERFACE_LINK_LIBRARIES
321
+ ${libs}
322
+ )
323
+
315
324
endif ()
316
325
317
326
@@ -402,30 +411,6 @@ endif(jdbc_test_stand_alone)
402
411
add_executable (jdbc_test jdbc_test.cc )
403
412
target_link_libraries (jdbc_test PRIVATE MySQL::conncpp-jdbc )
404
413
405
- if (WIN32 )
406
- # Connector needs to Link with Dnsapi
407
- target_link_libraries (jdbc_test PRIVATE Dnsapi )
408
- elseif (NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
409
- # Connector needs to Link with libresolv
410
- target_link_libraries (jdbc_test PRIVATE resolv )
411
- endif ()
412
-
413
- #
414
- # FreeBSD has other dependencies
415
- #
416
-
417
- if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
418
- target_link_libraries (jdbc_test PRIVATE execinfo unwind )
419
- endif ()
420
-
421
- #
422
- # We need to link to OpenSSL libraries too.
423
- #
424
-
425
- if (NOT WIN32 AND OPENSSL_FOUND )
426
- target_link_libraries (jdbc_test PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}
427
- )
428
- endif ()
429
414
430
415
#
431
416
# Set RPATH so that libraries in run/ folder are found by the executable
0 commit comments