# Conformance runner, C++ side. Owned by lane PROTO.
#
# Links libveloxproto (the generated wire code, ADR 0009's velox::proto target), not
# libveloxcore: this exercises the wire types, which is a separate concern from the engine.
#
# Linking the same target GUI and daemon link — rather than compiling
# core/generated/velox_proto.cpp into a second executable with its own flag set — is what
# guarantees the conformance suite is checking byte-identical generated code to what the
# clients ship. Two compiles of one .cpp under two warning configs is exactly the skew a
# conformance suite exists to catch.

if(TARGET velox::proto)
    add_executable(velox_conformance_cpp conformance_main.cpp)
    target_link_libraries(velox_conformance_cpp PRIVATE velox::proto)
else()
    # Standalone configure of tests/conformance/ with no core/ in the tree: compile the
    # generated source directly, as before the velox::proto target existed. Keeps the
    # suite buildable on its own.
    if(NOT TARGET nlohmann_json::nlohmann_json)
        find_package(nlohmann_json 3.11 REQUIRED)
    endif()
    add_executable(velox_conformance_cpp
        conformance_main.cpp
        ${CMAKE_SOURCE_DIR}/core/generated/velox_proto.cpp)
    target_include_directories(velox_conformance_cpp PRIVATE
        ${CMAKE_SOURCE_DIR}/core/generated)
    target_link_libraries(velox_conformance_cpp PRIVATE nlohmann_json::nlohmann_json)
endif()

target_include_directories(velox_conformance_cpp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(velox_conformance_cpp PRIVATE cxx_std_23)

# The runner needs the repository root so it can find contracts/fixtures.
add_test(NAME conformance_cpp
         COMMAND velox_conformance_cpp ${CMAKE_SOURCE_DIR})
set_tests_properties(conformance_cpp PROPERTIES LABELS "conformance")
