From 4c64d7daef8819d644ab78a911067b16943f023d Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 2 Feb 2026 22:50:17 +0100 Subject: build: Refactor CMake back to in-tree CMakeLists This moves the build definitions back to src/ subdirectories (CMakeLists.txt per component). Configuration and dependencies are kept out of tree. Configuration options are bundled into cmake/config/ modules. Dependencies are grouped by component (system/, crypt/, eth/, coverage/, etc.). It now consistently uses target-based commands (target_include_directories, target_link_libraries) instead of global include_directories(). Proper PRIVATE/PUBLIC visibility for executable link libraries. CONFIG_OUROBOROS_DEBUG now properly set based on being a valid debug config (not just checking the string name). It also adds OuroborosTargets export for find_package() support and CMake package config files (OuroborosConfig.cmake) for easier integration with CMake projects. The build logic now follows more idiomatic CMake practices with configuration separated from target definitions. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- cmake/utils/TestUtils.cmake | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'cmake/utils/TestUtils.cmake') diff --git a/cmake/utils/TestUtils.cmake b/cmake/utils/TestUtils.cmake index e40bdda1..e602690c 100644 --- a/cmake/utils/TestUtils.cmake +++ b/cmake/utils/TestUtils.cmake @@ -3,4 +3,36 @@ function(compute_test_prefix) file(RELATIVE_PATH _prefix "${CMAKE_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}") string(REGEX REPLACE "/tests$" "" _prefix "${_prefix}") set(TEST_PREFIX "${_prefix}" PARENT_SCOPE) -endfunction(compute_test_prefix) +endfunction() + +# Register tests from a test executable with the test framework +# Usage: ouroboros_register_tests(TARGET TESTS [ENVIRONMENT ]) +# The TESTS argument should be the test list variable created by create_test_sourcelist +function(ouroboros_register_tests) + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "TARGET;ENVIRONMENT" "TESTS") + + if(NOT ARG_TARGET) + message(FATAL_ERROR "ouroboros_register_tests: TARGET required") + endif() + + if(NOT ARG_TESTS) + message(FATAL_ERROR "ouroboros_register_tests: TESTS required") + endif() + + # First entry is the test driver, skip it + set(_tests ${ARG_TESTS}) + list(POP_FRONT _tests) + + foreach (test_src ${_tests}) + get_filename_component(test_name ${test_src} NAME_WE) + add_test(${TEST_PREFIX}/${test_name} + ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET} ${test_name}) + # All Ouroboros tests support skip return code + set_property(TEST ${TEST_PREFIX}/${test_name} PROPERTY SKIP_RETURN_CODE 1) + # Optional environment variables + if(ARG_ENVIRONMENT) + set_property(TEST ${TEST_PREFIX}/${test_name} + PROPERTY ENVIRONMENT "${ARG_ENVIRONMENT}") + endif() + endforeach () +endfunction() -- cgit v1.2.3