Files
psxrecomp/runtime/test_assertions.cmake
T
Matthew Stanley 65fd320fe5 test: restore optimized TAS and runtime regression gates
Keep assertions active only in test executables, expose an asset-free fixture aggregate, repair isolated link seams and stale expectations, and remove the obsolete hack-positive card test. Production runtime and emitter code and flags are unchanged. Validated with GNU 16.1 Release: 161 recompiler/TAS and 118 runtime tests enabled; existing disabled tests remain disabled.
2026-09-15 12:44:01 -07:00

38 lines
1.6 KiB
CMake

# Assertion-based fixtures must execute their checks in optimized builds too.
# Apply only to executable targets with test sources, never to runtime/emitter
# production targets or third-party libraries. Also expose an aggregate build
# target so asset-free CI can build fixtures without building a BIOS runtime.
# Call after declaring targets.
function(psxrecomp_enable_test_assertions)
if(NOT TARGET psxrecomp-test-fixtures)
add_custom_target(psxrecomp-test-fixtures)
endif()
set(_directory "${CMAKE_CURRENT_SOURCE_DIR}")
if(ARGC GREATER 0)
set(_directory "${ARGV0}")
endif()
get_property(_targets DIRECTORY "${_directory}" PROPERTY BUILDSYSTEM_TARGETS)
foreach(_target IN LISTS _targets)
get_target_property(_type ${_target} TYPE)
if(NOT _type STREQUAL "EXECUTABLE")
continue()
endif()
get_target_property(_sources ${_target} SOURCES)
foreach(_source IN LISTS _sources)
if(_source MATCHES "(^|[/\\\\])tests[/\\\\].*\\.(c|cc|cpp|cxx)$")
add_dependencies(psxrecomp-test-fixtures ${_target})
if(MSVC)
target_compile_options(${_target} PRIVATE /UNDEBUG)
else()
target_compile_options(${_target} PRIVATE -UNDEBUG)
endif()
break()
endif()
endforeach()
endforeach()
get_property(_children DIRECTORY "${_directory}" PROPERTY SUBDIRECTORIES)
foreach(_child IN LISTS _children)
psxrecomp_enable_test_assertions("${_child}")
endforeach()
endfunction()