Skip to content

Commit

Permalink
cmake: Fix build without benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Jan 9, 2025
1 parent 527d87d commit ea17c42
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit ea17c42

Please sign in to comment.