Ensure fmt dependency does not leak to downstream users

Fixes #1354
This commit is contained in:
Robert Adam
2026-06-13 20:05:37 +02:00
parent a9b2200789
commit 15f52c5229
4 changed files with 3 additions and 9 deletions

View File

@@ -139,9 +139,6 @@ elseif(NOT SOCI_FMT_BUILTIN)
endif()
endif()
# Name of the library to link with.
set(soci_fmt fmt::fmt)
if(soci_use_bundled_fmt)
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/3rdparty/fmt/CMakeLists.txt)
message(
@@ -152,9 +149,6 @@ if(soci_use_bundled_fmt)
endif()
add_subdirectory(3rdparty/fmt EXCLUDE_FROM_ALL)
# Use the header-only version to avoid forcing SOCI users to link with it.
set(soci_fmt $<BUILD_INTERFACE:fmt::fmt-header-only>)
endif()
# Helper function appending prefix and suffix to the library name.

View File

@@ -149,7 +149,7 @@ function(soci_define_backend_target)
endforeach()
# Set settings common to all backends.
target_link_libraries(${DEFINE_BACKEND_TARGET_NAME} PUBLIC SOCI::Core PRIVATE ${soci_fmt})
target_link_libraries(${DEFINE_BACKEND_TARGET_NAME} PUBLIC SOCI::Core PRIVATE $<BUILD_INTERFACE:fmt::fmt-header-only>)
target_include_directories(${DEFINE_BACKEND_TARGET_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/include/private")
soci_build_library_name(full_backend_target_name "${DEFINE_BACKEND_TARGET_NAME}")

View File

@@ -125,7 +125,7 @@ if (SOCI_SHARED)
target_compile_definitions(soci_core PUBLIC SOCI_DLL)
endif()
target_link_libraries(soci_core PRIVATE ${soci_fmt})
target_link_libraries(soci_core PRIVATE $<BUILD_INTERFACE:fmt::fmt-header-only>)
if (WITH_BOOST)
# Try and find Boost with the date_time component.

View File

@@ -33,7 +33,7 @@ target_link_libraries(soci_tests_common
PUBLIC
soci_compiler_interface
SOCI::Core
${soci_fmt}
$<BUILD_INTERFACE:fmt::fmt-header-only>
)
target_include_directories(soci_tests_common