@@ -206,10 +206,7 @@ IF(ENABLE_TLS)
206206 # Produce object files that contain debug info.
207207 target_compile_options (valkey_tls PRIVATE /Z7 )
208208 endif ()
209- TARGET_LINK_LIBRARIES (valkey_tls PRIVATE OpenSSL::SSL )
210- if (WIN32 OR CYGWIN )
211- target_link_libraries (valkey_tls PRIVATE valkey )
212- endif ()
209+ target_link_libraries (valkey_tls PRIVATE valkey::valkey OpenSSL::SSL )
213210 CONFIGURE_FILE (valkey_tls.pc.in valkey_tls.pc @ONLY )
214211
215212 INSTALL (TARGETS valkey_tls
@@ -261,7 +258,7 @@ if(ENABLE_RDMA)
261258 add_library (valkey_rdma ${valkey_rdma_sources} )
262259 add_library (valkey::valkey_rdma ALIAS valkey_rdma )
263260
264- target_link_libraries (valkey_rdma LINK_PRIVATE ${RDMACM_LIBRARIES} ${IBVERBS_LIBRARIES} )
261+ target_link_libraries (valkey_rdma PRIVATE valkey::valkey ${RDMACM_LIBRARIES} ${IBVERBS_LIBRARIES} )
265262 target_include_directories (valkey_rdma
266263 PRIVATE
267264 $<INSTALL_INTERFACE :include >
@@ -310,26 +307,31 @@ endif()
310307
311308# Add tests
312309if (NOT DISABLE_TESTS)
313- if (BUILD_SHARED_LIBS )
314- # Test using a static library since symbols are not hidden then.
315- # Use same source, include dirs and dependencies as the shared library.
316- add_library (valkey_unittest STATIC ${valkey_sources} )
317- get_target_property (include_directories valkey::valkey INCLUDE_DIRECTORIES )
318- target_include_directories (valkey_unittest PUBLIC ${include_directories} )
319- get_target_property (link_libraries valkey::valkey LINK_LIBRARIES )
320- if (link_libraries)
321- target_link_libraries (valkey_unittest PUBLIC ${link_libraries} )
322- endif ()
323- # Create libvalkey_unittest.a in the tests directory.
324- set_target_properties (valkey_unittest PROPERTIES
325- ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /tests" )
326- else ()
327- # Target is an alias for the static library.
328- add_library (valkey_unittest ALIAS valkey )
310+ # Unit tests uses a static library to ensure all symbols are visible.
311+ # This single library also bundles TLS and RDMA when enabled.
312+ add_library (valkey_unittest STATIC ${valkey_sources} ${valkey_tls_sources} ${valkey_rdma_sources} )
313+
314+ # Mirror the include directories.
315+ get_target_property (include_directories valkey::valkey INCLUDE_DIRECTORIES )
316+ target_include_directories (valkey_unittest PUBLIC ${include_directories} )
317+
318+ # Mirror the link libraries.
319+ get_target_property (link_libraries valkey::valkey LINK_LIBRARIES )
320+ if (link_libraries)
321+ target_link_libraries (valkey_unittest PUBLIC ${link_libraries} )
322+ endif ()
323+ if (ENABLE_TLS)
324+ target_link_libraries (valkey_unittest PRIVATE OpenSSL::SSL )
329325 endif ()
326+ if (ENABLE_RDMA)
327+ target_link_libraries (valkey_unittest PRIVATE ${RDMACM_LIBRARIES} ${IBVERBS_LIBRARIES} )
328+ endif ()
329+
330+ # Create libvalkey_unittest.a in the tests directory.
331+ set_target_properties (valkey_unittest PROPERTIES
332+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /tests" )
330333
331334 # Make sure ctest prints the output when a test fails.
332- # Must be set before including CTest.
333335 set (CMAKE_CTEST_ARGUMENTS "--output-on-failure" )
334336 include (CTest )
335337 add_subdirectory (tests )
0 commit comments