1 parent
3851aeb703
commit
053ee5b296
23 files changed
+845
-93
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# Isolated completeness probe used by cmake/Dependencies.cmake. Imported
|
||||
# targets created by a failed find_package stay scoped to this directory, so a
|
||||
# subsequent FetchContent fallback can define its own Boost targets safely.
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(_stacktrace_component stacktrace_windbg)
|
||||
else()
|
||||
set(_stacktrace_component stacktrace_addr2line)
|
||||
endif()
|
||||
find_package(Boost CONFIG QUIET
|
||||
COMPONENTS ${_stacktrace_component} url)
|
||||
|
||||
if(TARGET Boost::${_stacktrace_component} AND TARGET Boost::url)
|
||||
set_property(GLOBAL PROPERTY VOID_COMPLETE_SYSTEM_BOOST TRUE)
|
||||
endif()
|
||||
+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()
|
||||
|
||||
|
||||
+73
-3
@@ -35,15 +35,42 @@ function(void_add_module MODULE_NAME)
|
||||
target_sources(${TGT} PRIVATE ${SRC})
|
||||
target_compile_features(${TGT} PUBLIC cxx_std_26)
|
||||
endif()
|
||||
get_target_property(_module_target_type ${TGT} TYPE)
|
||||
if(_module_target_type STREQUAL "SHARED_LIBRARY" OR
|
||||
_module_target_type STREQUAL "MODULE_LIBRARY")
|
||||
# External packages are implementation details of compiled shared
|
||||
# modules: Void's installed public headers do not expose their types.
|
||||
# Keeping these links private also lets a shared Void SDK carry a
|
||||
# fetched runtime dependency without requiring that dependency's CMake
|
||||
# development package on every consumer machine.
|
||||
set(_external_scope PRIVATE)
|
||||
set(_record_external_dependencies FALSE)
|
||||
else()
|
||||
set(_external_scope ${SCOPE})
|
||||
set(_record_external_dependencies TRUE)
|
||||
endif()
|
||||
add_library(${ALIAS} ALIAS ${TGT})
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY VOID_MODULES ${MODULE_NAME})
|
||||
set(_module_external_deps "")
|
||||
foreach(ext_dep IN LISTS ARG_EXTERNAL_DEPS)
|
||||
string(REGEX REPLACE "::.*" "" BASE_DEP ${ext_dep})
|
||||
list(APPEND _module_external_deps ${BASE_DEP})
|
||||
# FindSQLite3's package name and imported-target namespace differ.
|
||||
# Preserve the package name in exported dependency metadata.
|
||||
if(ext_dep MATCHES "^SQLite::")
|
||||
set(BASE_DEP SQLite3)
|
||||
else()
|
||||
string(REGEX REPLACE "::.*" "" BASE_DEP ${ext_dep})
|
||||
endif()
|
||||
if(_record_external_dependencies)
|
||||
list(APPEND _module_external_deps ${BASE_DEP})
|
||||
endif()
|
||||
include(cmake/Dependencies.cmake)
|
||||
void_fetch_dependency(${BASE_DEP})
|
||||
if(NOT TARGET ${ext_dep})
|
||||
message(FATAL_ERROR
|
||||
"[Void] Dependency '${ext_dep}' required by module "
|
||||
"'${MODULE_NAME}' was not provided")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(_module_internal_deps ${ARG_INTERNAL_DEPS} ${ARG_OPTIONAL_DEPS})
|
||||
@@ -78,7 +105,41 @@ function(void_add_module MODULE_NAME)
|
||||
endif()
|
||||
|
||||
if(ARG_EXTERNAL_DEPS)
|
||||
target_link_libraries(${TGT} ${SCOPE} ${ARG_EXTERNAL_DEPS})
|
||||
if(_external_scope STREQUAL "PRIVATE")
|
||||
foreach(_external_dep IN LISTS ARG_EXTERNAL_DEPS)
|
||||
string(MAKE_C_IDENTIFIER "${_external_dep}"
|
||||
_external_dep_identifier)
|
||||
set(_build_external_target
|
||||
"_void_${MODULE_NAME}_${_external_dep_identifier}")
|
||||
add_library(${_build_external_target} INTERFACE IMPORTED)
|
||||
set_property(TARGET ${_build_external_target} PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "${_external_dep}")
|
||||
target_link_libraries(${TGT} PRIVATE
|
||||
"$<BUILD_INTERFACE:${_build_external_target}>")
|
||||
endforeach()
|
||||
else()
|
||||
# Keep fetched dependency build targets out of Void's install
|
||||
# export. Static and interface consumers still receive the same
|
||||
# canonical targets after find_dependency().
|
||||
foreach(_external_dep IN LISTS ARG_EXTERNAL_DEPS)
|
||||
string(MAKE_C_IDENTIFIER "${_external_dep}"
|
||||
_external_dep_identifier)
|
||||
set(_build_external_target
|
||||
"_void_${MODULE_NAME}_${_external_dep_identifier}")
|
||||
add_library(${_build_external_target} INTERFACE IMPORTED)
|
||||
set_property(TARGET ${_build_external_target} PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "${_external_dep}")
|
||||
# Defer namespace reconstruction until a consumer evaluates
|
||||
# the installed target. Otherwise CMake canonicalizes aliases
|
||||
# from a FetchContent dependency (Boost::url -> boost_url) and
|
||||
# requires the third-party target in Void's export set.
|
||||
string(REPLACE "::" "$<1:::>" _install_external_dep
|
||||
"${_external_dep}")
|
||||
target_link_libraries(${TGT} ${_external_scope}
|
||||
"$<BUILD_INTERFACE:${_build_external_target}>"
|
||||
"$<INSTALL_INTERFACE:${_install_external_dep}>")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(_lib IN LISTS ARG_DEPS_WIN32)
|
||||
@@ -140,6 +201,15 @@ function(void_add_module MODULE_NAME)
|
||||
CXX_EXTENSIONS OFF
|
||||
EXPORT_NAME ${MODULE_NAME}
|
||||
)
|
||||
if(UNIX AND _module_target_type STREQUAL "SHARED_LIBRARY")
|
||||
set_property(TARGET ${TGT} PROPERTY INSTALL_RPATH "$ORIGIN")
|
||||
endif()
|
||||
if(WIN32 AND _module_target_type STREQUAL "SHARED_LIBRARY")
|
||||
# Void's public headers do not require consumers to opt into a DLL
|
||||
# import macro. Generate the export table for compiled shared modules
|
||||
# so the same installed targets remain usable on Windows.
|
||||
set_property(TARGET ${TGT} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif()
|
||||
|
||||
# GCC 16+ exposes experimental C++26 reflection (P2996) via -freflection.
|
||||
# Apply it to every module unconditionally so any module is free to use
|
||||
|
||||
@@ -64,7 +64,20 @@ if(_void_external_deps)
|
||||
endif()
|
||||
foreach(dep IN LISTS _void_external_deps)
|
||||
if(dep STREQUAL "Boost")
|
||||
find_dependency(Boost REQUIRED COMPONENTS stacktrace_backtrace url)
|
||||
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)
|
||||
@@ -75,6 +88,11 @@ foreach(dep IN LISTS _void_external_deps)
|
||||
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()
|
||||
|
||||
@@ -51,7 +51,11 @@ foreach(line IN LISTS lines)
|
||||
if(_match)
|
||||
string(REGEX REPLACE "^[ \t]*class[ \t]+([A-Za-z_][A-Za-z0-9_]*)[ \t]*:.*" "\\1" fixture_class_name "${line}")
|
||||
set(in_fixture_class TRUE)
|
||||
string(REGEX MATCH "^[ \t]*" fixture_indent "${line}")
|
||||
# Derive indentation without an empty-match-capable regex. CMake 4
|
||||
# rejects such expressions even when the current input is non-empty.
|
||||
string(STRIP "${line}" _trimmed_fixture_line)
|
||||
string(FIND "${line}" "${_trimmed_fixture_line}" _indent_length)
|
||||
string(SUBSTRING "${line}" 0 ${_indent_length} fixture_indent)
|
||||
endif()
|
||||
|
||||
if(in_fixture_class)
|
||||
@@ -127,8 +131,17 @@ foreach(line IN LISTS lines)
|
||||
set(current_skip "")
|
||||
else()
|
||||
# If line is code (not comment/empty), break the comment association
|
||||
string(REGEX MATCH "^[ \t]*$" _is_empty "${line}")
|
||||
string(REGEX MATCH "^[ \t]*//" _is_comment "${line}")
|
||||
string(STRIP "${line}" _stripped_line)
|
||||
if(_stripped_line STREQUAL "")
|
||||
set(_is_empty TRUE)
|
||||
else()
|
||||
set(_is_empty FALSE)
|
||||
endif()
|
||||
if(line MATCHES "^[ \t]*//")
|
||||
set(_is_comment TRUE)
|
||||
else()
|
||||
set(_is_comment FALSE)
|
||||
endif()
|
||||
if(NOT _is_empty AND NOT _is_comment)
|
||||
set(current_tags "")
|
||||
set(current_skip "")
|
||||
|
||||
Reference in new issue
Block a user