89 lines
3.2 KiB
CMake
89 lines
3.2 KiB
CMake
include(FetchContent)
|
|
|
|
function(void_fetch_dependency DEP_NAME)
|
|
if(DEP_NAME STREQUAL "Boost")
|
|
# Components Void uses across modules: stacktrace_backtrace (Stacktrace),
|
|
# url + system (Net; beast/asio are header-only and come via Boost::headers).
|
|
if(TARGET Boost::stacktrace_backtrace AND TARGET Boost::url)
|
|
return()
|
|
endif()
|
|
|
|
# On modern Boost (1.85+) system/asio/beast are header-only and folded
|
|
# into Boost::headers; only stacktrace_backtrace and url are components.
|
|
find_package(Boost QUIET COMPONENTS stacktrace_backtrace url)
|
|
if(TARGET Boost::stacktrace_backtrace AND TARGET Boost::url)
|
|
return()
|
|
endif()
|
|
|
|
message(STATUS "[Void] Boost (stacktrace/url) not found — falling back to FetchContent")
|
|
set(BOOST_INCLUDE_LIBRARIES "stacktrace;url;system;beast;asio" CACHE STRING "" FORCE)
|
|
set(BOOST_ENABLE_CMAKE ON CACHE BOOL "" FORCE)
|
|
FetchContent_Declare(Boost
|
|
URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
|
|
URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e
|
|
EXCLUDE_FROM_ALL
|
|
)
|
|
FetchContent_MakeAvailable(Boost)
|
|
|
|
if(NOT TARGET Boost::stacktrace_backtrace AND TARGET boost_stacktrace_backtrace)
|
|
add_library(Boost::stacktrace_backtrace ALIAS boost_stacktrace_backtrace)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "OpenSSL")
|
|
if(NOT TARGET OpenSSL::SSL)
|
|
find_package(OpenSSL REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "Threads")
|
|
if(NOT TARGET Threads::Threads)
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
find_package(Threads REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "SQLite3")
|
|
if(NOT TARGET SQLite3::SQLite3)
|
|
find_package(SQLite3 REQUIRED)
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
if(DEP_NAME STREQUAL "Sodium")
|
|
if(TARGET Sodium::Sodium)
|
|
return()
|
|
endif()
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(SODIUM REQUIRED IMPORTED_TARGET libsodium)
|
|
add_library(Sodium::Sodium INTERFACE IMPORTED)
|
|
set_property(TARGET Sodium::Sodium PROPERTY
|
|
INTERFACE_LINK_LIBRARIES PkgConfig::SODIUM)
|
|
return()
|
|
endif()
|
|
# FIXME: Add if needed external
|
|
# if(DEP_NAME STREQUAL "glaze")
|
|
# if(NOT glaze_POPULATED)
|
|
# message(STATUS "[MyLib] Fetching Glaze on-demand...")
|
|
# FetchContent_Declare(glaze
|
|
# GIT_REPOSITORY https://github.com/stephenberry/glaze.git
|
|
# GIT_TAG v2.8.5
|
|
# )
|
|
# FetchContent_MakeAvailable(glaze)
|
|
# endif()
|
|
#
|
|
# elseif(DEP_NAME STREQUAL "fmt")
|
|
# if(NOT fmt_POPULATED)
|
|
# message(STATUS "[MyLib] Fetching fmt on-demand...")
|
|
# FetchContent_Declare(fmt
|
|
# GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
|
# GIT_TAG 10.2.1
|
|
# )
|
|
# FetchContent_MakeAvailable(fmt)
|
|
# endif()
|
|
# endif()
|
|
endfunction()
|