mirror of
https://github.com/SOCI/soci.git
synced 2026-02-13 17:18:35 -06:00
Re-add manual check for Boost to SOCI config file
Do it manually, i.e. separately from the code checking for the dependencies created by soci_public_dependency(), as Boost is a special case because it is optional and has an optional component.
This commit is contained in:
@@ -6,6 +6,8 @@ set(__dep_soci_comps "@SOCI_DEPENDENCY_SOCI_COMPONENTS@")
|
||||
set(__dep_names "@SOCI_DEPENDENCY_NAMES@")
|
||||
set(__dep_dep_targets "@SOCI_DEPENDENCY_TARGETS@")
|
||||
|
||||
set(__dep_soci_boost "@SOCI_DEPENDENCY_BOOST@")
|
||||
set(__dep_soci_boost_components "@SOCI_DEPENDENCY_BOOST_COMPONENTS@")
|
||||
|
||||
set(__prev_module_path "${CMAKE_MODULE_PATH}")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/find_package_files/")
|
||||
@@ -28,6 +30,28 @@ endif()
|
||||
list(REMOVE_ITEM SOCI_FIND_COMPONENTS Core)
|
||||
list(INSERT SOCI_FIND_COMPONENTS 0 Core)
|
||||
|
||||
# Check (optional) Core dependency on Boost.
|
||||
if (${__dep_soci_boost})
|
||||
if (NOT "${__dep_soci_boost_components}" STREQUAL "")
|
||||
set(SOCI_BOOST_COMPONENTS COMPONENTS ${__dep_soci_boost_components})
|
||||
endif()
|
||||
|
||||
# Don't use REQUIRED to be able to give a better error message below.
|
||||
find_package(Boost ${SOCI_BOOST_COMPONENTS} ${__quiet})
|
||||
|
||||
if (NOT Boost_FOUND)
|
||||
set(SOCI_FOUND FALSE)
|
||||
set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency 'Boost' for SOCI component 'Core'")
|
||||
else()
|
||||
# Check for all the components too
|
||||
foreach (__soci_boost_component IN LISTS __dep_soci_boost_components)
|
||||
if (NOT TARGET Boost::${__soci_boost_component})
|
||||
set(SOCI_FOUND FALSE)
|
||||
set(SOCI_NOT_FOUND_MESSAGE "Unmet dependency 'Boost::${__soci_boost_component}' for SOCI component 'Core'")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(LENGTH __dep_soci_comps __list_size)
|
||||
foreach (__item IN ITEMS __dep_names __dep_dep_targets)
|
||||
|
||||
@@ -79,6 +79,7 @@ if (WITH_BOOST)
|
||||
# we found only Boost headers, but not the date_time library.
|
||||
if (TARGET Boost::date_time)
|
||||
set(SOCI_BOOST_DATE_TIME_MESSAGE " (with date_time component)")
|
||||
set(SOCI_DEPENDENCY_BOOST_COMPONENTS "date_time" CACHE INTERNAL "Boost components used by SOCI")
|
||||
|
||||
target_link_libraries(soci_core PUBLIC Boost::date_time)
|
||||
target_compile_definitions(soci_core PUBLIC SOCI_HAVE_BOOST_DATE_TIME)
|
||||
@@ -96,6 +97,7 @@ if (WITH_BOOST)
|
||||
# find_package() call or just Boost headers in the second one.
|
||||
if (Boost_FOUND)
|
||||
message(STATUS "Found Boost: v${Boost_VERSION_STRING} in ${Boost_INCLUDE_DIRS}${SOCI_BOOST_DATE_TIME_MESSAGE}")
|
||||
set(SOCI_DEPENDENCY_BOOST TRUE CACHE INTERNAL "Whether SOCI depends on Boost")
|
||||
|
||||
target_link_libraries(soci_core PUBLIC Boost::boost Boost::disable_autolinking)
|
||||
target_compile_definitions(soci_core PUBLIC SOCI_HAVE_BOOST)
|
||||
|
||||
Reference in New Issue
Block a user