- Literal transliteration of `Statement.closedForm` plus an equivalent summarised implementation - Borrowed input keys (`std::string_view` / `std::span`) and owned result keys (`std::string`) - Golden-vector test, differential/safety fuzzers, and a nanobench comparison The literal and summarised implementations agree on 40,000 Lean golden vectors, 18,971 sorted corpus cases, and the readable fuzzer; the raw fuzzer runs both implementations under ASan/UBSan. `build/` and the generated `oracle/golden.txt` are ignored.
60 lines
2.4 KiB
CMake
60 lines
2.4 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)
|
|
|
|
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)
|
|
|
|
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()
|