From 348957245d770700b646c7d798d6873f1ddcb221 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 13 Mar 2026 19:24:27 +0100 Subject: [PATCH 1/3] Don't make SOCI compiler interface part of its public interface The options in soci_compiler_interface enabling (or even disabling) various warnings shouldn't be used for compiling the application code. --- src/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index eba855a1..f1529fe0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -162,7 +162,7 @@ if (WITH_BOOST) endif() target_link_libraries(soci_core - PUBLIC + PRIVATE $ ) From d4807763cc2687cf18346f2db263e40f514a0ae8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 13 Mar 2026 19:25:56 +0100 Subject: [PATCH 2/3] Optimize CMake look by breaking from it immediately This change is done mostly not for run-time optimizations purposes but to show that we don't need to continue iterating after missing at least one missing target dependency. --- cmake/soci_utils.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/soci_utils.cmake b/cmake/soci_utils.cmake index 40e35341..67d7b917 100644 --- a/cmake/soci_utils.cmake +++ b/cmake/soci_utils.cmake @@ -115,6 +115,7 @@ function(soci_public_dependency) foreach (TGT IN LISTS PUBLIC_DEP_DEP_TARGETS) if (NOT TARGET "${TGT}") set(SKIP_SEARCH OFF) + break() endif() endforeach() From 7d652b8f2ab70cda77cd6f0e2e0235cb0f6be3a9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 13 Mar 2026 19:26:49 +0100 Subject: [PATCH 3/3] Skip searching for dependencies if their targets already exist This is useful when the library is used as a sub-project by a super-project which has already defined targets for various dependencies (e.g. typically because it bundles them together with SOCI too). This is more than just an optimization as searching for the dependency could (and typically would, when they're bundled as mentioned above) fail, while skipping it allows the configuration and build to succeed. --- cmake/soci_define_backend_target.cmake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/soci_define_backend_target.cmake b/cmake/soci_define_backend_target.cmake index 580670d5..1cdbd41b 100644 --- a/cmake/soci_define_backend_target.cmake +++ b/cmake/soci_define_backend_target.cmake @@ -85,6 +85,22 @@ function(soci_define_backend_target) list(GET CURRENT_DEP_SEARCH 0 CURRENT_DEP) + # Don't search for the dependency if it had been already predefined. + set(SKIP_DEP_SEARCH ON) + foreach (CURRENT IN LISTS CURRENT_DEP_TARGETS) + if(NOT TARGET ${CURRENT}) + set(SKIP_DEP_SEARCH OFF) + break() + endif() + endforeach() + + if(SKIP_DEP_SEARCH) + list(APPEND PUBLIC_DEP_CALL_ARGS + "NAME ${CURRENT_DEP} DEP_TARGETS ${CURRENT_DEP_TARGETS} TARGET SOCI::${DEFINE_BACKEND_NAME}" + ) + continue() + endif() + find_package(${CURRENT_DEP_SEARCH} ${REQUIRE_FLAG}) if (NOT ${CURRENT_DEP}_FOUND) @@ -103,7 +119,7 @@ function(soci_define_backend_target) else() message(FATAL_ERROR "Unspecified handling of unmet dependency") endif() - else() + else() # Dependency was found. # This is wasteful, but do it again without "QUIET" flag to show the result if it succeeded. if (REQUIRE_FLAG STREQUAL "QUIET") find_package(${CURRENT_DEP_SEARCH})