cmake_minimum_required(VERSION 3.20)
project(WinDevVplProbe LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_subdirectory(../../third_party/vpl_full_renderer renderer)
add_library(vpl_raster_probe SHARED probe.cpp)
target_include_directories(vpl_raster_probe PRIVATE ../../third_party/vpl_full_renderer/reference)
target_link_libraries(vpl_raster_probe PRIVATE vpl_backend)
target_compile_options(vpl_raster_probe PRIVATE -fno-fast-math -ffp-contract=off)

# Allocation substitution is test-only. Each executable owns its raster.c;
# the backend archive supplies only the otherwise-unresolved compiler/converter.
enable_testing()
foreach(floor 524288 1)
  add_executable(surface_pool_checks_${floor} surface_pool_checks.c)
  target_include_directories(surface_pool_checks_${floor} PRIVATE ../../third_party/vpl_full_renderer/reference .)
  target_compile_definitions(surface_pool_checks_${floor} PRIVATE V64_RENDER_ALLOC_TEST V64C_NO_MAIN V64R_MAX_WORKERS=1 V64R_SURFACE_POOL_BYTES=16777216 V64R_SURFACE_POOL_MIN_BYTES=${floor} V64R_SERIAL_BAND_BYTES=393216)
  target_compile_options(surface_pool_checks_${floor} PRIVATE -fno-fast-math -ffp-contract=off)
  target_link_libraries(surface_pool_checks_${floor} PRIVATE vpl_backend)
  add_test(NAME surface_pool_${floor} COMMAND surface_pool_checks_${floor})
endforeach()
