Skip to content

Commit fe6c503

Browse files
committed
Add define for static build google benchmark.
1 parent 9c0fd44 commit fe6c503

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

benchmarks/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if(NOT build)
1111
endif()
1212

1313
find_package(benchmark REQUIRED)
14+
get_target_property(BenchmarkBuildType benchmark::benchmark TYPE)
15+
1416
add_custom_target(run_benchmarks)
1517

1618
PCL_ADD_BENCHMARK(features_normal_3d FILES features/normal_3d.cpp

cmake/pcl_targets.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ function(PCL_ADD_BENCHMARK _name)
441441
target_link_libraries(benchmark_${_name} benchmark::benchmark ${ARGS_LINK_WITH})
442442
set_target_properties(benchmark_${_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
443443

444+
# See https://github.com/google/benchmark/issues/1457
445+
if(BenchmarkBuildType STREQUAL "STATIC_LIBRARY" AND benchmark_VERSION STREQUAL "1.7.0")
446+
target_compile_definitions(benchmark_${_name} PUBLIC -DBENCHMARK_STATIC_DEFINE)
447+
endif()
448+
444449
#Only applies to MSVC
445450
if(MSVC)
446451
#Requires CMAKE version 3.13.0

0 commit comments

Comments
 (0)