Files
conflict-range/cpp/CMakeLists.txt
T
andrew a0b68d148b Simplify crossed dispatch and add SMT-derived cases
Drop the redundant begin.offset split in crossedCompleteOvershoot and
the rE > 0 guard in closedFormForwardSaturated; both are implied by
the call-site invariants.

Add an SMT-derived empty-interval case as the smt_cases CTest and as a
committed fuzz_readable seed.  run-fuzz.sh now loads the read-only seed
corpus alongside the writable one.

Rename exhaustive to sweep and document that it is exhaustive only
over its bounded family of instances.
2026-11-18 13:03:55 -05:00

84 lines
3.5 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(conflict_range_cpp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
option(CR_BUILD_FUZZERS "Build libFuzzer differential/safety harnesses" ON)
option(CR_BUILD_BENCH "Build the nanobench comparison" ON)
enable_testing()
add_library(cr_literal STATIC src/literal.cpp)
target_include_directories(cr_literal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_library(cr_fast STATIC src/fast.cpp)
target_include_directories(cr_fast PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
# Golden-vector check: the literal translation against vectors produced by
# `lake env lean --run cpp/oracle/gen.lean`.
add_executable(golden_test tests/golden.cpp)
target_link_libraries(golden_test PRIVATE cr_literal)
# Literal vs. fast on Lean-generated cases that satisfy the readable sorting
# invariant.
add_executable(diff_corpus tests/diff_corpus.cpp)
target_link_libraries(diff_corpus PRIVATE cr_literal cr_fast)
# Regression test for offsets at the extremes of `Int`.
add_executable(extreme_test tests/extreme.cpp)
target_include_directories(extreme_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(extreme_test PRIVATE cr_literal cr_fast)
# Deterministic sweep over a finite class of small readable instances. This is
# the driver for the line-coverage check in `run-coverage.sh`.
add_executable(sweep_test tests/sweep.cpp)
target_include_directories(sweep_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(sweep_test PRIVATE cr_literal cr_fast)
set(CR_GOLDEN_VECTORS "${CMAKE_CURRENT_SOURCE_DIR}/oracle/golden.txt")
add_test(NAME golden COMMAND golden_test "${CR_GOLDEN_VECTORS}")
add_test(NAME diff_corpus COMMAND diff_corpus "${CR_GOLDEN_VECTORS}")
# Curated readable cases found by SMT-assisted mutation analysis.
add_test(NAME smt_cases COMMAND diff_corpus
"${CMAKE_CURRENT_SOURCE_DIR}/tests/smt_cases.txt")
add_test(NAME extreme COMMAND extreme_test)
add_test(NAME sweep COMMAND sweep_test)
if(CR_BUILD_BENCH)
add_executable(cr_bench tests/bench.cpp)
target_include_directories(cr_bench PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party
${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_link_libraries(cr_bench PRIVATE cr_literal cr_fast)
target_compile_definitions(cr_bench PRIVATE NDEBUG)
endif()
if(CR_BUILD_FUZZERS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CR_FUZZ_FLAGS -fsanitize=fuzzer,address,undefined
-fno-sanitize-recover=all -g -O1)
# Compile the implementations into each fuzz target directly, so that the
# library code itself is instrumented (linking a plain static library would
# only instrument the harness).
add_executable(fuzz_readable tests/fuzz_readable.cpp src/literal.cpp
src/fast.cpp)
target_include_directories(fuzz_readable PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_compile_options(fuzz_readable PRIVATE ${CR_FUZZ_FLAGS})
target_link_options(fuzz_readable PRIVATE -fsanitize=fuzzer,address,undefined)
add_executable(fuzz_raw tests/fuzz_raw.cpp src/literal.cpp src/fast.cpp)
target_include_directories(fuzz_raw PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/tests)
target_compile_options(fuzz_raw PRIVATE ${CR_FUZZ_FLAGS})
target_link_options(fuzz_raw PRIVATE -fsanitize=fuzzer,address,undefined)
endif()