77 lines
2.5 KiB
CMake
77 lines
2.5 KiB
CMake
# ── Google Benchmark (FetchContent) ──
|
|
include(FetchContent)
|
|
|
|
find_package(benchmark QUIET)
|
|
if(NOT benchmark_FOUND)
|
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
|
FetchContent_Declare(
|
|
google_benchmark
|
|
URL https://github.com/google/benchmark/archive/refs/tags/v1.8.3.tar.gz
|
|
)
|
|
FetchContent_MakeAvailable(google_benchmark)
|
|
endif()
|
|
|
|
# ── Benchmark helper header ──
|
|
# Provides vde::bench::measure_ms() chrono fallback if benchmark not available
|
|
# (benchmark:: is still preferred when linked)
|
|
|
|
# ── main entry ──
|
|
add_executable(vde_bench
|
|
bench_main.cpp
|
|
)
|
|
target_link_libraries(vde_bench PRIVATE vde benchmark::benchmark)
|
|
|
|
# ── BVH ──
|
|
add_executable(vde_bench_bvh
|
|
bench_main.cpp bench_bvh.cpp
|
|
)
|
|
target_link_libraries(vde_bench_bvh PRIVATE vde benchmark::benchmark)
|
|
|
|
# ── Delaunay ──
|
|
add_executable(vde_bench_delaunay
|
|
bench_main.cpp bench_delaunay.cpp
|
|
)
|
|
target_link_libraries(vde_bench_delaunay PRIVATE vde benchmark::benchmark)
|
|
|
|
# ── Boolean (needs all component libs because INTERFACE deps may not resolve)
|
|
add_executable(vde_bench_boolean
|
|
bench_main.cpp bench_boolean.cpp
|
|
)
|
|
target_link_libraries(vde_bench_boolean PRIVATE
|
|
vde_foundation vde_core vde_curves vde_mesh vde_spatial vde_collision
|
|
vde_boolean vde_brep vde_sketch benchmark::benchmark
|
|
)
|
|
|
|
# ── Curves ──
|
|
add_executable(vde_bench_curves
|
|
bench_main.cpp bench_curves.cpp
|
|
)
|
|
target_link_libraries(vde_bench_curves PRIVATE vde benchmark::benchmark)
|
|
|
|
# ── Spatial (R-Tree / KD-Tree) ──
|
|
add_executable(vde_bench_spatial
|
|
bench_main.cpp bench_spatial.cpp
|
|
)
|
|
target_link_libraries(vde_bench_spatial PRIVATE vde benchmark::benchmark)
|
|
|
|
# ── Convenience target: build all benchmarks ──
|
|
add_custom_target(vde_benchmarks
|
|
DEPENDS
|
|
vde_bench
|
|
vde_bench_bvh
|
|
vde_bench_delaunay
|
|
|
|
vde_bench_curves
|
|
vde_bench_spatial
|
|
COMMENT "All benchmarks built"
|
|
)
|
|
|
|
# ── CTest integration: register benchmarks with optional args ──
|
|
# Run individual benchmarks via: ctest -R bench_
|
|
enable_testing()
|
|
add_test(NAME bench_bvh COMMAND vde_bench_bvh --benchmark_min_time=0.01s)
|
|
add_test(NAME bench_delaunay COMMAND vde_bench_delaunay --benchmark_min_time=0.01s)
|
|
add_test(NAME bench_boolean COMMAND vde_bench_boolean --benchmark_min_time=0.01s)
|
|
add_test(NAME bench_curves COMMAND vde_bench_curves --benchmark_min_time=0.01s)
|
|
add_test(NAME bench_spatial COMMAND vde_bench_spatial --benchmark_min_time=0.01s)
|