1 parent
3851aeb703
commit
053ee5b296
23 files changed
+845
-93
No files matched your search
+110
-13
@@ -1,33 +1,127 @@
|
||||
include(FetchContent)
|
||||
|
||||
function(void_ensure_boost_header_targets)
|
||||
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_${_component})
|
||||
add_library(Boost::${_component} ALIAS boost_${_component})
|
||||
elseif(NOT TARGET Boost::${_component} AND TARGET Boost::headers)
|
||||
# System Boost packages commonly expose one aggregate include
|
||||
# target rather than per-header-library targets.
|
||||
add_library(Boost::${_component} INTERFACE IMPORTED)
|
||||
set_property(TARGET Boost::${_component} PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES Boost::headers)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(void_install_fetched_boost_runtime)
|
||||
get_property(_runtime_registered GLOBAL
|
||||
PROPERTY VOID_FETCHED_BOOST_RUNTIME_REGISTERED)
|
||||
if(_runtime_registered)
|
||||
return()
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY VOID_FETCHED_BOOST_RUNTIME_REGISTERED TRUE)
|
||||
|
||||
# Boost disables its install rules when consumed through add_subdirectory.
|
||||
# Register the selected shared runtime closure explicitly so an installed
|
||||
# shared Void package never points back into its build tree.
|
||||
foreach(_target IN ITEMS
|
||||
boost_container
|
||||
boost_context
|
||||
boost_coroutine
|
||||
boost_date_time
|
||||
boost_stacktrace_addr2line
|
||||
boost_stacktrace_windbg
|
||||
boost_url)
|
||||
if(TARGET ${_target})
|
||||
get_target_property(_type ${_target} TYPE)
|
||||
if(_type STREQUAL "SHARED_LIBRARY" OR
|
||||
_type STREQUAL "MODULE_LIBRARY")
|
||||
if(UNIX)
|
||||
set_property(TARGET ${_target} PROPERTY
|
||||
INSTALL_RPATH "$ORIGIN")
|
||||
endif()
|
||||
install(TARGETS ${_target}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
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)
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(_stacktrace_component stacktrace_windbg)
|
||||
else()
|
||||
set(_stacktrace_component stacktrace_addr2line)
|
||||
endif()
|
||||
|
||||
# Components Void uses across modules: a platform Stacktrace backend,
|
||||
# plus url, beast, and asio (Net).
|
||||
if(TARGET Boost::${_stacktrace_component} AND TARGET Boost::url)
|
||||
void_ensure_boost_header_targets()
|
||||
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)
|
||||
# Probe in a child directory because a failed component-aware
|
||||
# find_package(Boost) can still leave partial imported targets such as
|
||||
# Boost::headers in its directory scope. Those partial targets collide
|
||||
# with Boost's FetchContent build. Imported targets created by this
|
||||
# probe stay in the child scope; only a boolean result is exported.
|
||||
get_property(_boost_probe_ran GLOBAL
|
||||
PROPERTY VOID_COMPLETE_SYSTEM_BOOST SET)
|
||||
if(NOT _boost_probe_ran)
|
||||
set_property(GLOBAL PROPERTY VOID_COMPLETE_SYSTEM_BOOST FALSE)
|
||||
add_subdirectory(
|
||||
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/BoostProbe"
|
||||
"${PROJECT_BINARY_DIR}/void-boost-probe"
|
||||
EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
get_property(_complete_system_boost GLOBAL
|
||||
PROPERTY VOID_COMPLETE_SYSTEM_BOOST)
|
||||
if(_complete_system_boost)
|
||||
# On modern Boost, beast/asio are header-only and folded into
|
||||
# Boost::headers. The fetched Asio target carries its own System
|
||||
# dependency; requiring a separate system component here rejects
|
||||
# otherwise complete distro packages where Boost.System is folded
|
||||
# into Boost::headers.
|
||||
find_package(Boost CONFIG REQUIRED
|
||||
COMPONENTS ${_stacktrace_component} url)
|
||||
void_ensure_boost_header_targets()
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(TARGET Boost::headers OR TARGET Boost::boost)
|
||||
message(FATAL_ERROR
|
||||
"[Void] Incomplete Boost targets already exist in the parent "
|
||||
"project. Provide ${_stacktrace_component} and url before "
|
||||
"adding Void, or let Void resolve Boost first.")
|
||||
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)
|
||||
# Keep Boost's selection local to this dependency resolution. Avoid
|
||||
# overwriting a parent project's cache when Void is embedded.
|
||||
set(BOOST_INCLUDE_LIBRARIES "stacktrace;url;system;beast;asio")
|
||||
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)
|
||||
if(NOT TARGET Boost::${_stacktrace_component} AND
|
||||
TARGET boost_${_stacktrace_component})
|
||||
add_library(Boost::${_stacktrace_component}
|
||||
ALIAS boost_${_stacktrace_component})
|
||||
endif()
|
||||
void_ensure_boost_header_targets()
|
||||
void_install_fetched_boost_runtime()
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -47,9 +141,12 @@ function(void_fetch_dependency DEP_NAME)
|
||||
endif()
|
||||
|
||||
if(DEP_NAME STREQUAL "SQLite3")
|
||||
if(NOT TARGET SQLite3::SQLite3)
|
||||
if(NOT TARGET SQLite3::SQLite3 AND NOT TARGET SQLite::SQLite3)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
endif()
|
||||
if(NOT TARGET SQLite3::SQLite3 AND TARGET SQLite::SQLite3)
|
||||
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in new issue
Block a user