cmake_minimum_required( VERSION 3.20 )
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../src)
add_executable( toy_calc toy_calc.cpp )
target_link_libraries( toy_calc cparse )
# Smoke test: pins the walkthrough's documented "Trying it" transcript.
# Regression guard — the example's code (copied straight into
# content/walkthrough/en/toy-calc.md's fenced block) was never actually
# build-tested before and had a real compile bug (missing <optional>,
# unqualified ParseError) that went unnoticed for a while.
add_test(
NAME toy_calc.smoke
COMMAND ${CMAKE_COMMAND}
-DEXE=$<TARGET_FILE:toy_calc>
-DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/../tests/input.txt
-DEXPECTED=${CMAKE_CURRENT_SOURCE_DIR}/../tests/expected.txt
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../run_and_diff.cmake
)