build: reconcile module dependency closures, Log.hpp ownership, and consumer tests (X-BASE-03)
This commit is contained in:
1 parent
e385746b74
commit
cd6fc7e5f5
19 files changed
+318
-52
No files matched your search
+36
-13
@@ -4,7 +4,7 @@ set_property(GLOBAL PROPERTY VOID_PENDING_OPTIONAL_DEPS "")
|
||||
|
||||
function(void_add_module MODULE_NAME)
|
||||
cmake_parse_arguments(ARG "" ""
|
||||
"INTERNAL_DEPS;EXTERNAL_DEPS;OPTIONAL_DEPS;DEPS_WIN32;DEPS_UNIX;OPTIONS_WIN32;OPTIONS_UNIX"
|
||||
"INTERNAL_DEPS;EXTERNAL_DEPS;OPTIONAL_DEPS;DEPS_WIN32;DEPS_UNIX;OPTIONS_WIN32;OPTIONS_UNIX;EXTRA_HEADERS;EXCLUDE_HEADERS"
|
||||
${ARGN})
|
||||
|
||||
set(TGT ${PROJECT_NAME}_${MODULE_NAME})
|
||||
@@ -12,6 +12,15 @@ function(void_add_module MODULE_NAME)
|
||||
|
||||
file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/${MODULE_NAME}/*.cpp")
|
||||
file(GLOB_RECURSE HDR CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/Void/${MODULE_NAME}/*.hpp")
|
||||
foreach(_excl IN LISTS ARG_EXCLUDE_HEADERS)
|
||||
list(REMOVE_ITEM HDR "${CMAKE_CURRENT_SOURCE_DIR}/include/${_excl}")
|
||||
endforeach()
|
||||
foreach(_extra IN LISTS ARG_EXTRA_HEADERS)
|
||||
list(APPEND HDR "${CMAKE_CURRENT_SOURCE_DIR}/include/${_extra}")
|
||||
endforeach()
|
||||
if(HDR)
|
||||
list(REMOVE_DUPLICATES HDR)
|
||||
endif()
|
||||
|
||||
if(NOT SRC AND NOT HDR)
|
||||
return()
|
||||
@@ -202,7 +211,10 @@ function(void_add_module MODULE_NAME)
|
||||
EXPORT_NAME ${MODULE_NAME}
|
||||
)
|
||||
if(UNIX AND _module_target_type STREQUAL "SHARED_LIBRARY")
|
||||
set_property(TARGET ${TGT} PROPERTY INSTALL_RPATH "$ORIGIN")
|
||||
set_target_properties(${TGT} PROPERTIES
|
||||
INSTALL_RPATH "$ORIGIN"
|
||||
INSTALL_RPATH_USE_LINK_PATH TRUE
|
||||
)
|
||||
endif()
|
||||
if(WIN32 AND _module_target_type STREQUAL "SHARED_LIBRARY")
|
||||
# Void's public headers do not require consumers to opt into a DLL
|
||||
@@ -212,23 +224,34 @@ function(void_add_module MODULE_NAME)
|
||||
endif()
|
||||
|
||||
# GCC 16+ exposes experimental C++26 reflection (P2996) via -freflection.
|
||||
# Apply it to every module unconditionally so any module is free to use
|
||||
# ^^T / std::meta::* without per-module wiring.
|
||||
if(SRC AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16)
|
||||
target_compile_options(${TGT} PUBLIC -freflection)
|
||||
# Propagate it on every module (including INTERFACE modules like Core and
|
||||
# Data) so standalone installed consumers receive the required flag.
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16)
|
||||
target_compile_options(${TGT} ${SCOPE}
|
||||
"$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,16>>:-freflection>")
|
||||
endif()
|
||||
if(HDR)
|
||||
target_sources(${TGT} ${SCOPE} FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${HDR})
|
||||
endif()
|
||||
target_sources(${TGT} ${SCOPE} FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${HDR})
|
||||
target_include_directories(${TGT} ${SCOPE}
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
install(TARGETS ${TGT} EXPORT ${EXPORT_SET_NAME}
|
||||
FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
if(HDR)
|
||||
install(TARGETS ${TGT} EXPORT ${EXPORT_SET_NAME}
|
||||
FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
else()
|
||||
install(TARGETS ${TGT} EXPORT ${EXPORT_SET_NAME}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Resolve OPTIONAL_DEPS recorded by void_add_module(). Must be called once
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Detail/Repr.hpp>
|
||||
@@ -1,3 +1,3 @@
|
||||
void_add_module(Configuration
|
||||
INTERNAL_DEPS Functional System Data Time
|
||||
INTERNAL_DEPS Core Functional System Data Time LogState
|
||||
)
|
||||
@@ -1 +1,3 @@
|
||||
void_add_module(Containers)
|
||||
void_add_module(Containers
|
||||
INTERNAL_DEPS Core
|
||||
)
|
||||
@@ -1,3 +1,3 @@
|
||||
void_add_module(Data
|
||||
INTERNAL_DEPS Time
|
||||
INTERNAL_DEPS Core Time
|
||||
)
|
||||
@@ -1,3 +1,3 @@
|
||||
void_add_module(Fsm
|
||||
INTERNAL_DEPS Async Data Functional Log Service
|
||||
INTERNAL_DEPS Async Core Data Functional Log Service
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
void_add_module(FunctionalCoreFormatting
|
||||
INTERNAL_DEPS Functional Core
|
||||
)
|
||||
@@ -1,4 +1,5 @@
|
||||
void_add_module(Log
|
||||
INTERNAL_DEPS Functional Configuration
|
||||
INTERNAL_DEPS Async Core Data Functional Configuration LogState
|
||||
OPTIONAL_DEPS Stacktrace
|
||||
EXCLUDE_HEADERS Void/Log/Log.hpp
|
||||
)
|
||||
@@ -1 +1,3 @@
|
||||
void_add_module(LogState)
|
||||
void_add_module(LogState
|
||||
EXTRA_HEADERS Void/Log/Log.hpp
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
void_add_module(Plugin
|
||||
INTERNAL_DEPS Functional System Data
|
||||
INTERNAL_DEPS Functional System Data LogState Text Service
|
||||
DEPS_UNIX dl
|
||||
)
|
||||
@@ -1,3 +1,3 @@
|
||||
void_add_module(Service
|
||||
INTERNAL_DEPS Functional Log
|
||||
INTERNAL_DEPS Core Functional LogState
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
void_add_module(Testing
|
||||
INTERNAL_DEPS LogState
|
||||
INTERNAL_DEPS Core Functional Time LogState
|
||||
OPTIONAL_DEPS Stacktrace Log Async Configuration Text
|
||||
)
|
||||
@@ -1 +1,3 @@
|
||||
void_add_module(TestingMock INTERNAL_DEPS Testing Functional)
|
||||
void_add_module(TestingMock
|
||||
INTERNAL_DEPS Core Testing Functional
|
||||
)
|
||||
+55
-16
@@ -1,7 +1,32 @@
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/VoidTesting.cmake)
|
||||
|
||||
if(NOT TARGET Void::Testing)
|
||||
message(FATAL_ERROR
|
||||
"[Void] VOID_ENABLE_TESTING=ON requires the Testing module to be enabled "
|
||||
"(include Testing in VOID_ENABLED_MODULES or set -DVOID_ENABLE_TESTING=OFF).")
|
||||
endif()
|
||||
|
||||
get_property(ACTIVE_MODULES GLOBAL PROPERTY VOID_MODULES)
|
||||
|
||||
function(_void_test_requires_satisfied src_file active_modules out_var)
|
||||
file(READ "${src_file}" _src_content)
|
||||
string(REGEX MATCHALL "#[ \t]*include[ \t]*[<\"](Void/[^/\">]+)/[^>\"]+[>\"]"
|
||||
_matches "${_src_content}")
|
||||
set(_ok TRUE)
|
||||
foreach(_m IN LISTS _matches)
|
||||
if(_m MATCHES "Void/([^/\">]+)/")
|
||||
set(_req "${CMAKE_MATCH_1}")
|
||||
if(NOT _req STREQUAL "Detail" AND NOT _req IN_LIST active_modules)
|
||||
set(_ok FALSE)
|
||||
message(STATUS
|
||||
"[VoidTests] Skipping ${src_file} (requires unselected module '${_req}')")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${out_var} "${_ok}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(_gen_dir "${CMAKE_CURRENT_BINARY_DIR}/void_testing_generated")
|
||||
file(MAKE_DIRECTORY "${_gen_dir}")
|
||||
|
||||
@@ -24,6 +49,10 @@ foreach(mod ${ACTIVE_MODULES})
|
||||
|
||||
file(GLOB _test_files CONFIGURE_DEPENDS "${_mod_dir}/*.cpp")
|
||||
foreach(_src ${_test_files})
|
||||
_void_test_requires_satisfied("${_src}" "${ACTIVE_MODULES}" _deps_ok)
|
||||
if(NOT _deps_ok)
|
||||
continue()
|
||||
endif()
|
||||
get_filename_component(_stem "${_src}" NAME_WE)
|
||||
set(_gen "${_gen_dir}/${mod}_${_stem}.void_tests.cpp")
|
||||
|
||||
@@ -47,6 +76,10 @@ endforeach()
|
||||
|
||||
file(GLOB_RECURSE _internal_sources CONFIGURE_DEPENDS "internal/*.cpp")
|
||||
foreach(_src ${_internal_sources})
|
||||
_void_test_requires_satisfied("${_src}" "${ACTIVE_MODULES}" _deps_ok)
|
||||
if(NOT _deps_ok)
|
||||
continue()
|
||||
endif()
|
||||
get_filename_component(_stem "${_src}" NAME_WE)
|
||||
set(_gen "${_gen_dir}/internal_${_stem}.void_tests.cpp")
|
||||
|
||||
@@ -92,6 +125,7 @@ if(_all_generated)
|
||||
|
||||
add_test(NAME VoidTests COMMAND VoidTests)
|
||||
|
||||
string(REPLACE ";" "," _active_modules_csv "${ACTIVE_MODULES}")
|
||||
add_test(NAME VoidInstalledComponentConsumers
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DVOID_BUILD_DIR=${CMAKE_BINARY_DIR}
|
||||
@@ -99,6 +133,9 @@ if(_all_generated)
|
||||
-DVOID_TEST_ROOT=${CMAKE_CURRENT_BINARY_DIR}/package-consumer
|
||||
-DVOID_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
-DVOID_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
|
||||
-DVOID_GENERATOR=${CMAKE_GENERATOR}
|
||||
-DVOID_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
||||
-DVOID_ACTIVE_MODULES=${_active_modules_csv}
|
||||
-DVOID_BUILD_CONFIG=$<CONFIG>
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/package/InstalledComponents.cmake
|
||||
)
|
||||
@@ -122,7 +159,7 @@ if(TARGET VoidTests AND TARGET Void::System)
|
||||
add_dependencies(VoidTests VoidProcessHelper)
|
||||
endif()
|
||||
|
||||
if(TARGET Void::Plugin)
|
||||
if(TARGET VoidTests AND TARGET Void::Plugin)
|
||||
set(_test_plugin_src "${CMAKE_CURRENT_SOURCE_DIR}/plugins/TestPlugin.cpp")
|
||||
if(EXISTS "${_test_plugin_src}")
|
||||
add_library(VoidTestPlugin SHARED "${_test_plugin_src}")
|
||||
@@ -148,22 +185,24 @@ if(TARGET Void::Plugin)
|
||||
|
||||
# Stateful plugins (schema v1 + v2) for hot-reload/state-migration
|
||||
# tests. Same plugin name; v2 adds a field and migrates v1 JSON.
|
||||
add_library(VoidStatefulPluginV1 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/StatefulPluginV1.cpp")
|
||||
add_library(VoidStatefulPluginV2 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/StatefulPluginV2.cpp")
|
||||
foreach(_sp VoidStatefulPluginV1 VoidStatefulPluginV2)
|
||||
target_link_libraries(${_sp} PRIVATE Void::Plugin Void::Data)
|
||||
target_include_directories(${_sp} PRIVATE
|
||||
if(TARGET Void::Data)
|
||||
add_library(VoidStatefulPluginV1 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/StatefulPluginV1.cpp")
|
||||
add_library(VoidStatefulPluginV2 SHARED
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins/StatefulPluginV2.cpp")
|
||||
foreach(_sp VoidStatefulPluginV1 VoidStatefulPluginV2)
|
||||
target_link_libraries(${_sp} PRIVATE Void::Plugin Void::Data)
|
||||
target_include_directories(${_sp} PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
endforeach()
|
||||
target_compile_definitions(VoidTests PRIVATE
|
||||
"VOID_STATEFUL_V1_PATH=\"$<TARGET_FILE:VoidStatefulPluginV1>\""
|
||||
"VOID_STATEFUL_V2_PATH=\"$<TARGET_FILE:VoidStatefulPluginV2>\""
|
||||
)
|
||||
target_include_directories(VoidTests PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
endforeach()
|
||||
target_compile_definitions(VoidTests PRIVATE
|
||||
"VOID_STATEFUL_V1_PATH=\"$<TARGET_FILE:VoidStatefulPluginV1>\""
|
||||
"VOID_STATEFUL_V2_PATH=\"$<TARGET_FILE:VoidStatefulPluginV2>\""
|
||||
)
|
||||
target_include_directories(VoidTests PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/plugins")
|
||||
add_dependencies(VoidTests VoidStatefulPluginV1 VoidStatefulPluginV2)
|
||||
add_dependencies(VoidTests VoidStatefulPluginV1 VoidStatefulPluginV2)
|
||||
endif()
|
||||
|
||||
# Service plugins (a plugin provides an IService-derived interface) for
|
||||
# the FSM x Service hot-reload integration test. Same plugin name; v2
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidEmbeddedConsumer LANGUAGES CXX)
|
||||
|
||||
set(VOID_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../.." CACHE PATH "Path to VoidLibrary source")
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Parent static policy" FORCE)
|
||||
set(VOID_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
set(VOID_ENABLED_MODULES "Math;Text;Time;Functional;Binary" CACHE STRING "" FORCE)
|
||||
|
||||
add_subdirectory("${VOID_SOURCE_DIR}" void_subbuild)
|
||||
|
||||
add_executable(void_embedded_consumer main.cpp)
|
||||
target_link_libraries(void_embedded_consumer PRIVATE
|
||||
Void::Math
|
||||
Void::Text
|
||||
Void::Time
|
||||
Void::Functional
|
||||
Void::Binary
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidEmbeddedConsumer COMMAND void_embedded_consumer)
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <Void/Binary/Reader.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/Math/Numeric.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
#include <Void/Time/Stopwatch.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
const auto r = Void::Numeric::checked_mul(6, 7);
|
||||
if (!r || *r != 42) {
|
||||
return 1;
|
||||
}
|
||||
if (Void::Str::to_upper("ok") != "OK") {
|
||||
return 1;
|
||||
}
|
||||
const std::array bytes{std::byte{0x2A}};
|
||||
Void::Binary::Reader reader{bytes};
|
||||
const auto b = reader.read<std::uint8_t>(std::endian::big);
|
||||
Void::Time::Stopwatch sw;
|
||||
sw.start();
|
||||
(void)sw.stop();
|
||||
const auto res = Void::Result::ok(b.value_or(0));
|
||||
return res && *res == 42 ? 0 : 1;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidFoundationConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS
|
||||
Math
|
||||
Text
|
||||
Time
|
||||
Functional
|
||||
Binary
|
||||
FunctionalCoreFormatting
|
||||
)
|
||||
|
||||
add_executable(void_foundation_consumer main.cpp)
|
||||
target_link_libraries(void_foundation_consumer PRIVATE
|
||||
Void::Math
|
||||
Void::Text
|
||||
Void::Time
|
||||
Void::Functional
|
||||
Void::Binary
|
||||
Void::FunctionalCoreFormatting
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidFoundationConsumer COMMAND void_foundation_consumer)
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <Void/Binary/Reader.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/FunctionalCoreFormatting/Repr.hpp>
|
||||
#include <Void/Math/Numeric.hpp>
|
||||
#include <Void/Text/Str.hpp>
|
||||
#include <Void/Time/Stopwatch.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Point {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
int main()
|
||||
{
|
||||
const auto sum = Void::Numeric::checked_add(19, 23);
|
||||
if (!sum || *sum != 42) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto trimmed = Void::Str::trim(" void ");
|
||||
if (trimmed != "void") {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Void::Time::Stopwatch sw;
|
||||
sw.start();
|
||||
(void)sw.stop();
|
||||
|
||||
const std::array bytes{std::byte{0x00}, std::byte{0x2A}};
|
||||
Void::Binary::Reader reader{bytes};
|
||||
const auto num = reader.read<std::uint16_t>(std::endian::big);
|
||||
if (!num || *num != 42) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto r = Void::Result::ok(Point{1, 2});
|
||||
const auto text = Void::Result::Detail::repr(*r);
|
||||
return !text.empty() ? 0 : 1;
|
||||
}
|
||||
@@ -9,6 +9,26 @@ endforeach()
|
||||
|
||||
file(REMOVE_RECURSE "${VOID_TEST_ROOT}")
|
||||
set(install_prefix "${VOID_TEST_ROOT}/install")
|
||||
set(relocated_prefix "${VOID_TEST_ROOT}/relocated-install")
|
||||
|
||||
set(_active_modules "")
|
||||
if(DEFINED VOID_ACTIVE_MODULES AND NOT VOID_ACTIVE_MODULES STREQUAL "")
|
||||
string(REPLACE "," ";" _active_modules "${VOID_ACTIVE_MODULES}")
|
||||
endif()
|
||||
|
||||
function(has_modules out_var)
|
||||
if(NOT _active_modules)
|
||||
set(${out_var} TRUE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
foreach(m IN LISTS ARGN)
|
||||
if(NOT m IN_LIST _active_modules)
|
||||
set(${out_var} FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${out_var} TRUE PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(install_command "${CMAKE_COMMAND}" --install "${VOID_BUILD_DIR}"
|
||||
--prefix "${install_prefix}")
|
||||
@@ -17,12 +37,23 @@ if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
endif()
|
||||
execute_process(COMMAND ${install_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
function(run_consumer name)
|
||||
set(_gen_args "")
|
||||
if(DEFINED VOID_GENERATOR AND NOT VOID_GENERATOR STREQUAL "")
|
||||
list(APPEND _gen_args -G "${VOID_GENERATOR}")
|
||||
endif()
|
||||
if(DEFINED VOID_MAKE_PROGRAM AND NOT VOID_MAKE_PROGRAM STREQUAL "")
|
||||
list(APPEND _gen_args "-DCMAKE_MAKE_PROGRAM=${VOID_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
set(_consumers_run 0)
|
||||
|
||||
function(run_consumer name prefix_dir build_subdir)
|
||||
set(source_dir "${VOID_TEST_SOURCE_DIR}/${name}")
|
||||
set(build_dir "${VOID_TEST_ROOT}/${name}")
|
||||
set(build_dir "${VOID_TEST_ROOT}/${build_subdir}")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${build_dir}"
|
||||
"-DCMAKE_PREFIX_PATH=${install_prefix}"
|
||||
${_gen_args}
|
||||
"-DCMAKE_PREFIX_PATH=${prefix_dir}"
|
||||
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
||||
${ARGN}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
@@ -36,11 +67,11 @@ function(run_consumer name)
|
||||
endif()
|
||||
execute_process(COMMAND ${build_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND ${test_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
math(EXPR _next "${_consumers_run} + 1")
|
||||
set(_consumers_run "${_next}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
run_consumer(Binary
|
||||
set(_no_external_deps
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
@@ -48,14 +79,52 @@ run_consumer(Binary
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=TRUE)
|
||||
|
||||
# Exercise the transitive dependency closure for every newly extracted runtime
|
||||
# module while proving unrelated Sodium and SQLite dependencies are not loaded.
|
||||
run_consumer(Audited
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
has_modules(_has_binary Binary)
|
||||
if(_has_binary)
|
||||
run_consumer(Binary "${install_prefix}" "Binary" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
# Foundation consumer with Core-formatting bridge and zero external packages.
|
||||
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Core)
|
||||
if(_has_foundation)
|
||||
run_consumer(Foundation "${install_prefix}" "Foundation" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
# Exercise the transitive dependency closure for runtime modules while proving
|
||||
# unrelated Sodium and SQLite dependencies are not loaded.
|
||||
has_modules(_has_audited Archive Binary Crypto Plugin System Update)
|
||||
if(_has_audited)
|
||||
run_consumer(Audited "${install_prefix}" "Audited"
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
endif()
|
||||
|
||||
# Compiled shared modules keep their third-party implementation dependencies
|
||||
# private, but every installed runtime library must remain linkable and
|
||||
# executable from a clean consumer project.
|
||||
run_consumer(External)
|
||||
has_modules(_has_external Net Security Sqlite Stacktrace)
|
||||
if(_has_external)
|
||||
run_consumer(External "${install_prefix}" "External")
|
||||
endif()
|
||||
|
||||
if(_consumers_run EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"VoidInstalledComponentConsumers ran 0 consumers for active modules '${VOID_ACTIVE_MODULES}'")
|
||||
endif()
|
||||
|
||||
# Relocatability verification: rename the install tree so original install path
|
||||
# no longer exists, then configure/build/run consumers against relocated path.
|
||||
file(RENAME "${install_prefix}" "${relocated_prefix}")
|
||||
|
||||
if(_has_foundation)
|
||||
run_consumer(Foundation "${relocated_prefix}" "RelocatedFoundation" ${_no_external_deps})
|
||||
elseif(_has_binary)
|
||||
run_consumer(Binary "${relocated_prefix}" "RelocatedBinary" ${_no_external_deps})
|
||||
endif()
|
||||
|
||||
if(_has_external)
|
||||
run_consumer(External "${relocated_prefix}" "RelocatedExternal")
|
||||
endif()
|
||||
Reference in new issue
Block a user