From ea17c42a2133066a8249849b711de9769a38dc90 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Thu, 9 Jan 2025 17:55:42 +0100 Subject: [PATCH] cmake: Fix build without benchmark --- benchmark/CMakeLists.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 06f5cef56..53805c4df 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -6,7 +6,10 @@ # --- BENCHMARK -------------------------------------- # ---------------------------------------------------- add_custom_target(bench) -add_project_private_dependency(benchmark REQUIRED) + +if(BUILD_BENCHMARK) + add_project_private_dependency(benchmark REQUIRED) +endif() macro(ADD_PINOCCHIO_BENCH bench_name) set(options HEADER_ONLY GOOGLE_BENCHMARK) @@ -16,22 +19,20 @@ macro(ADD_PINOCCHIO_BENCH bench_name) if(BUILD_BENCHMARK) add_executable(${bench_name} ${bench_name}.cpp) - else() - add_executable(${bench_name} EXCLUDE_FROM_ALL ${bench_name}.cpp) - endif() - target_compile_definitions(${bench_name} PRIVATE PINOCCHIO_MODEL_DIR="${PINOCCHIO_MODEL_DIR}") - if(NOT unit_test_HEADER_ONLY) - target_link_libraries(${bench_name} PRIVATE pinocchio_default) - else() - target_link_libraries(${bench_name} PRIVATE pinocchio_headers) - endif() + target_compile_definitions(${bench_name} PRIVATE PINOCCHIO_MODEL_DIR="${PINOCCHIO_MODEL_DIR}") + if(NOT unit_test_HEADER_ONLY) + target_link_libraries(${bench_name} PRIVATE pinocchio_default) + else() + target_link_libraries(${bench_name} PRIVATE pinocchio_headers) + endif() - if(unit_test_GOOGLE_BENCHMARK) - target_link_libraries(${bench_name} PRIVATE benchmark::benchmark) - endif() + if(unit_test_GOOGLE_BENCHMARK) + target_link_libraries(${bench_name} PRIVATE benchmark::benchmark) + endif() - add_dependencies(bench ${bench_name}) + add_dependencies(bench ${bench_name}) + endif() endmacro() # timings