118 lines
4.2 KiB
CMake
118 lines
4.2 KiB
CMake
@PACKAGE_INIT@
|
|
|
|
include(CMakeFindDependencyMacro)
|
|
|
|
set(_void_known_modules "@VOID_MODULES_LIST@")
|
|
set(_void_module_dependency_records "@VOID_MODULE_DEPENDENCY_RECORDS@")
|
|
|
|
function(_void_module_dependencies module out_internal out_external)
|
|
foreach(record IN LISTS _void_module_dependency_records)
|
|
string(REPLACE "|" ";" fields "${record}")
|
|
list(GET fields 0 record_module)
|
|
if(NOT record_module STREQUAL module)
|
|
continue()
|
|
endif()
|
|
|
|
list(GET fields 1 internal_csv)
|
|
list(GET fields 2 external_csv)
|
|
if(internal_csv STREQUAL "-")
|
|
set(internal "")
|
|
else()
|
|
string(REPLACE "," ";" internal "${internal_csv}")
|
|
endif()
|
|
if(external_csv STREQUAL "-")
|
|
set(external "")
|
|
else()
|
|
string(REPLACE "," ";" external "${external_csv}")
|
|
endif()
|
|
set(${out_internal} "${internal}" PARENT_SCOPE)
|
|
set(${out_external} "${external}" PARENT_SCOPE)
|
|
return()
|
|
endforeach()
|
|
set(${out_internal} "" PARENT_SCOPE)
|
|
set(${out_external} "" PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
# With no requested components, preserve the historical all-modules package
|
|
# behavior. Component-aware consumers resolve only the transitive dependencies
|
|
# of the modules they explicitly request.
|
|
if(Void_FIND_COMPONENTS)
|
|
set(_void_pending_modules ${Void_FIND_COMPONENTS})
|
|
else()
|
|
set(_void_pending_modules ${_void_known_modules})
|
|
endif()
|
|
|
|
set(_void_required_modules "")
|
|
while(_void_pending_modules)
|
|
list(POP_FRONT _void_pending_modules module)
|
|
if(NOT module IN_LIST _void_known_modules OR
|
|
module IN_LIST _void_required_modules)
|
|
continue()
|
|
endif()
|
|
list(APPEND _void_required_modules "${module}")
|
|
_void_module_dependencies("${module}" internal_deps external_deps)
|
|
list(APPEND _void_pending_modules ${internal_deps})
|
|
endwhile()
|
|
|
|
set(_void_external_deps "")
|
|
foreach(module IN LISTS _void_required_modules)
|
|
_void_module_dependencies("${module}" internal_deps external_deps)
|
|
list(APPEND _void_external_deps ${external_deps})
|
|
endforeach()
|
|
if(_void_external_deps)
|
|
list(REMOVE_DUPLICATES _void_external_deps)
|
|
endif()
|
|
foreach(dep IN LISTS _void_external_deps)
|
|
if(dep STREQUAL "Boost")
|
|
find_dependency(Boost CONFIG REQUIRED COMPONENTS
|
|
@VOID_BOOST_STACKTRACE_COMPONENT@ url)
|
|
if(NOT TARGET Boost::headers AND TARGET Boost::boost)
|
|
add_library(Boost::headers INTERFACE IMPORTED)
|
|
set_property(TARGET Boost::headers PROPERTY
|
|
INTERFACE_LINK_LIBRARIES Boost::boost)
|
|
endif()
|
|
foreach(_component IN ITEMS beast asio)
|
|
if(NOT TARGET Boost::${_component} AND TARGET Boost::headers)
|
|
add_library(Boost::${_component} INTERFACE IMPORTED)
|
|
set_property(TARGET Boost::${_component} PROPERTY
|
|
INTERFACE_LINK_LIBRARIES Boost::headers)
|
|
endif()
|
|
endforeach()
|
|
elseif(dep STREQUAL "Sodium")
|
|
find_dependency(PkgConfig REQUIRED)
|
|
pkg_check_modules(SODIUM REQUIRED IMPORTED_TARGET libsodium)
|
|
if(NOT TARGET Sodium::Sodium)
|
|
add_library(Sodium::Sodium INTERFACE IMPORTED)
|
|
set_property(TARGET Sodium::Sodium PROPERTY
|
|
INTERFACE_LINK_LIBRARIES PkgConfig::SODIUM)
|
|
endif()
|
|
elseif(dep STREQUAL "LibArchive")
|
|
find_dependency(LibArchive REQUIRED)
|
|
elseif(dep STREQUAL "SQLite3")
|
|
find_dependency(SQLite3 REQUIRED)
|
|
if(NOT TARGET SQLite3::SQLite3 AND TARGET SQLite::SQLite3)
|
|
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
|
endif()
|
|
elseif(NOT TARGET ${dep})
|
|
find_dependency(${dep})
|
|
endif()
|
|
endforeach()
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_SET_NAME@.cmake")
|
|
|
|
foreach(component IN LISTS Void_FIND_COMPONENTS)
|
|
if(TARGET Void::${component})
|
|
set(Void_${component}_FOUND TRUE)
|
|
else()
|
|
set(Void_${component}_FOUND FALSE)
|
|
endif()
|
|
endforeach()
|
|
|
|
# Auto-load the testing helper so consumers get void_add_tests + the
|
|
# auto-scan sweep just by find_package(Void).
|
|
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/VoidTesting.cmake")
|
|
include("${CMAKE_CURRENT_LIST_DIR}/VoidTesting.cmake")
|
|
endif()
|
|
|
|
check_required_components("@PROJECT_NAME@")
|