368 lines
14 KiB
CMake
368 lines
14 KiB
CMake
cmake_minimum_required(VERSION 4.0)
|
|
|
|
foreach(required IN ITEMS VOID_BUILD_DIR VOID_TEST_SOURCE_DIR VOID_TEST_ROOT
|
|
VOID_CXX_COMPILER VOID_CTEST_COMMAND)
|
|
if(NOT DEFINED ${required} OR "${${required}}" STREQUAL "")
|
|
message(FATAL_ERROR "${required} is required")
|
|
endif()
|
|
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}")
|
|
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
|
list(APPEND install_command --config "${VOID_BUILD_CONFIG}")
|
|
endif()
|
|
execute_process(COMMAND ${install_command} COMMAND_ERROR_IS_FATAL ANY)
|
|
|
|
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}/${build_subdir}")
|
|
execute_process(
|
|
COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${build_dir}"
|
|
${_gen_args}
|
|
"-DCMAKE_PREFIX_PATH=${prefix_dir}"
|
|
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
|
${ARGN}
|
|
COMMAND_ERROR_IS_FATAL ANY)
|
|
|
|
set(build_command "${CMAKE_COMMAND}" --build "${build_dir}")
|
|
set(test_command "${VOID_CTEST_COMMAND}" --test-dir "${build_dir}"
|
|
--output-on-failure)
|
|
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
|
list(APPEND build_command --config "${VOID_BUILD_CONFIG}")
|
|
list(APPEND test_command -C "${VOID_BUILD_CONFIG}")
|
|
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()
|
|
|
|
set(_no_external_deps
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=TRUE)
|
|
|
|
# A header-only component must remain independently consumable even when every
|
|
# optional external package is explicitly unavailable.
|
|
has_modules(_has_core Core)
|
|
if(_has_core)
|
|
run_consumer(CoreOnly "${install_prefix}" "CoreOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_memory Memory Core)
|
|
if(_has_memory)
|
|
run_consumer(MemoryOnly "${install_prefix}" "MemoryOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_binary Binary Memory Functional Core)
|
|
if(_has_binary)
|
|
run_consumer(Binary "${install_prefix}" "Binary" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_algorithms Algorithms Math Core)
|
|
if(_has_algorithms)
|
|
run_consumer(AlgorithmsOnly "${install_prefix}" "AlgorithmsOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_unicode Unicode Text Core)
|
|
if(_has_unicode)
|
|
run_consumer(UnicodeOnly "${install_prefix}" "UnicodeOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_io IO Async Memory Time Functional Core)
|
|
if(_has_io)
|
|
run_consumer(IOOnly "${install_prefix}" "IOOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_runtime Runtime IO Async Algorithms Memory Time Functional Core)
|
|
if(_has_runtime)
|
|
run_consumer(RuntimeOnly "${install_prefix}" "RuntimeOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_system System Functional Time LogState)
|
|
if(_has_system)
|
|
run_consumer(SystemOnly "${install_prefix}" "SystemOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_system_async SystemAsync System Async IO Time Functional LogState)
|
|
if(_has_system_async)
|
|
run_consumer(SystemAsyncOnly "${install_prefix}" "SystemAsyncOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_ipc IPC Core Functional Memory Time Binary Async IO Resilience ObservabilityHooks)
|
|
if(_has_ipc)
|
|
run_consumer(IPCOnly "${install_prefix}" "IPCOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_obs_hooks ObservabilityHooks)
|
|
if(_has_obs_hooks)
|
|
run_consumer(ObservabilityHooksOnly "${install_prefix}" "ObservabilityHooksOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_obs Observability ObservabilityHooks Memory Time Functional Core)
|
|
if(_has_obs)
|
|
run_consumer(ObservabilityOnly "${install_prefix}" "ObservabilityOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_resilience Resilience ObservabilityHooks Time Functional Core)
|
|
if(_has_resilience)
|
|
run_consumer(ResilienceOnly "${install_prefix}" "ResilienceOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_log Log Async Data Time Memory Functional Core LogState)
|
|
if(_has_log)
|
|
run_consumer(LogOnly "${install_prefix}" "LogOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_crypto Crypto Functional)
|
|
if(_has_crypto)
|
|
run_consumer(CryptoOnly "${install_prefix}" "CryptoOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_crypto_async CryptoAsync Crypto IO Async Time Functional)
|
|
if(_has_crypto_async)
|
|
run_consumer(CryptoAsyncOnly "${install_prefix}" "CryptoAsyncOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_security Security Time Functional)
|
|
if(_has_security)
|
|
run_consumer(SecurityOnly "${install_prefix}" "SecurityOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_security_async SecurityAsync Security Async Time Resilience Functional)
|
|
if(_has_security_async)
|
|
run_consumer(SecurityAsyncOnly "${install_prefix}" "SecurityAsyncOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_archive Archive System Time Functional)
|
|
if(_has_archive)
|
|
run_consumer(ArchiveOnly "${install_prefix}" "ArchiveOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_update Update Archive Crypto Data Functional System Text Time)
|
|
if(_has_update)
|
|
run_consumer(UpdateOnly "${install_prefix}" "UpdateOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_sqlite Sqlite Functional Time)
|
|
if(_has_sqlite)
|
|
run_consumer(SqliteOnly "${install_prefix}" "SqliteOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_sqlite_async SqliteAsync Sqlite Async Time Functional LogState)
|
|
if(_has_sqlite_async)
|
|
run_consumer(SqliteAsyncOnly "${install_prefix}" "SqliteAsyncOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_storage Storage Core Functional Time Memory Binary IO Async)
|
|
if(_has_storage)
|
|
run_consumer(StorageOnly "${install_prefix}" "StorageOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_service Service Core Functional Time Async LogState)
|
|
if(_has_service)
|
|
run_consumer(ServiceOnly "${install_prefix}" "ServiceOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_service_plugin ServicePlugin Service Plugin Functional System Data LogState Text Time Async Core)
|
|
if(_has_service_plugin)
|
|
run_consumer(ServicePluginOnly "${install_prefix}" "ServicePluginOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_plugin Plugin Core Functional System Data Time Async LogState Text Service)
|
|
if(_has_plugin)
|
|
run_consumer(PluginOnly "${install_prefix}" "PluginOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_configuration Configuration Core Functional System Data Time LogState)
|
|
if(_has_configuration)
|
|
run_consumer(ConfigurationOnly "${install_prefix}" "ConfigurationOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_configuration_async ConfigurationAsync Configuration SystemAsync Async Time Functional LogState)
|
|
if(_has_configuration_async)
|
|
run_consumer(ConfigurationAsyncOnly "${install_prefix}" "ConfigurationAsyncOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_fsm Fsm Async Core Data Functional Time Log Service)
|
|
if(_has_fsm)
|
|
run_consumer(FsmOnly "${install_prefix}" "FsmOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_net Net Functional Text Time)
|
|
if(_has_net)
|
|
run_consumer(NetOnly "${install_prefix}" "NetOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_testing_mock TestingMock Testing Functional Core)
|
|
if(_has_testing_mock)
|
|
run_consumer(TestingMockOnly "${install_prefix}" "TestingMockOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_short_url ShortUrl Service Time Functional)
|
|
if(_has_short_url)
|
|
run_consumer(ShortUrlOnly "${install_prefix}" "ShortUrlOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
has_modules(_has_rpc RPC Net Binary Data Time Async Functional Core)
|
|
if(_has_rpc)
|
|
run_consumer(RpcOnly "${install_prefix}" "RpcOnly"
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
|
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
|
endif()
|
|
|
|
has_modules(_has_discovery Discovery Core Functional Time Async)
|
|
if(_has_discovery)
|
|
run_consumer(DiscoveryOnly "${install_prefix}" "DiscoveryOnly" ${_no_external_deps})
|
|
endif()
|
|
|
|
# Foundation consumer with Core-formatting bridge and zero external packages.
|
|
has_modules(_has_foundation Math Text Time Functional Binary FunctionalCoreFormatting Memory 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.
|
|
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()
|