Merge branch 'cmake-superproject-fixes'

Fixes for using library from a super-project

See #1338.
This commit is contained in:
Vadim Zeitlin
2026-03-14 19:51:09 +01:00
3 changed files with 19 additions and 2 deletions

View File

@@ -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})

View File

@@ -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()

View File

@@ -162,7 +162,7 @@ if (WITH_BOOST)
endif()
target_link_libraries(soci_core
PUBLIC
PRIVATE
$<BUILD_INTERFACE:soci_compiler_interface>
)