Files
Library/tests/package/InstalledComponents.cmake
faumaray 053ee5b296
CI / GCC 16 / C++26 / sanitizers (push) Failing after 4s
CI / GCC 16 / C++26 / werror (push) Failing after 3s
CI / GCC 16 / C++26 / default (push) Failing after 1m48s
update
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-25 23:42:52 +03:00

62 lines
2.6 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(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)
function(run_consumer name)
set(source_dir "${VOID_TEST_SOURCE_DIR}/${name}")
set(build_dir "${VOID_TEST_ROOT}/${name}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${build_dir}"
"-DCMAKE_PREFIX_PATH=${install_prefix}"
"-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)
endfunction()
# A header-only component must remain independently consumable even when every
# optional external package is explicitly unavailable.
run_consumer(Binary
-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)
# 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)
# 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)