proto: link velox::proto in the C++ conformance runner, per CORE's request

core/docs/proto-requests-conformance-cmake.md: the runner's header comment
said it links libveloxproto, but it actually compiled
core/generated/velox_proto.cpp straight into the executable and found
nlohmann_json itself — the only option while ADR 0009's target didn't exist.
It exists now on main as velox::proto (core/CMakeLists.txt, PUBLIC generated
include dir, PUBLIC nlohmann_json).

if(TARGET velox::proto): link it. else: fall back to compiling the generated
.cpp directly, for a configure with no core/ in the tree. Both paths verified
— full tree links libveloxproto.a (compiled once, by veloxproto's own
target); with core/CMakeLists.txt hidden the fallback compiles the .cpp and
finds nlohmann itself. conformance_cpp passes either way.

Beyond tidiness: once GUI links velox::proto too, the conformance runner
linking the same target is what guarantees the suite and the clients exercise
byte-identical generated code, rather than two compiles of one .cpp under two
warning configs — the exact skew a conformance suite exists to catch.

run.sh's own direct g++ compile is unaffected and stays independent by
design; this only changes the ctest-driven path CI and lanes use.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fgjnqFCS5h5L7gZTZo3rV
This commit is contained in:
2026-09-10 14:50:26 +04:00
co-authored by Claude Sonnet 5
parent 1fabaf805d
commit 9dce588456
+25 -18
View File
@@ -1,27 +1,34 @@
# Conformance runner, C++ side. Owned by lane PROTO.
#
# Links libveloxproto (the generated protocol code in core/generated/), not libveloxcore:
# this exercises the wire types, which is a separate concern from the engine. See
# docs/adr/0009-generated-protocol-library.md.
# 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.
# The root CMakeLists.txt only find_package(nlohmann_json)'s when daemon/CMakeLists.txt
# exists (daemon is its real consumer), so this target may not exist yet when this
# directory configures on its own — this suite must not depend on daemon having landed.
# Self-sufficient rather than reaching into the root file to widen that guard.
if(NOT TARGET nlohmann_json::nlohmann_json)
find_package(nlohmann_json 3.11 REQUIRED)
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()
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
${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(velox_conformance_cpp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(velox_conformance_cpp PRIVATE cxx_std_23)
target_link_libraries(velox_conformance_cpp PRIVATE nlohmann_json::nlohmann_json)
# The runner needs the repository root so it can find contracts/fixtures.
add_test(NAME conformance_cpp