build: only build all benchmarks if explicitly requested

This commit is contained in:
Marcus Holland-Moritz 2025-04-20 00:02:35 +02:00
parent 02b12418cc
commit 195c7e1461
2 changed files with 31 additions and 18 deletions

View File

@ -124,6 +124,9 @@ case "-$BUILD_TYPE-" in
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release" CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release"
if [[ "-$BUILD_TYPE-" != *-minimal-* ]]; then if [[ "-$BUILD_TYPE-" != *-minimal-* ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_BENCHMARKS=1" CMAKE_ARGS="${CMAKE_ARGS} -DWITH_BENCHMARKS=1"
if [[ "-$BUILD_TYPE-" != *-lto-* ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_ALL_BENCHMARKS=1"
fi
fi fi
if [[ "-$BUILD_TYPE-" == *-static-* ]]; then if [[ "-$BUILD_TYPE-" == *-static-* ]]; then
export CFLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -fmerge-all-constants" export CFLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -fmerge-all-constants"
@ -135,6 +138,9 @@ case "-$BUILD_TYPE-" in
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=MinSizeRel" CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=MinSizeRel"
if [[ "-$BUILD_TYPE-" != *-minimal-* ]]; then if [[ "-$BUILD_TYPE-" != *-minimal-* ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_BENCHMARKS=1" CMAKE_ARGS="${CMAKE_ARGS} -DWITH_BENCHMARKS=1"
if [[ "-$BUILD_TYPE-" != *-lto-* ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DWITH_ALL_BENCHMARKS=1"
fi
fi fi
if [[ "-$BUILD_TYPE-" == *-static-* ]]; then if [[ "-$BUILD_TYPE-" == *-static-* ]]; then
export CFLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -fmerge-all-constants" export CFLAGS="-ffunction-sections -fdata-sections -fvisibility=hidden -fmerge-all-constants"

View File

@ -31,6 +31,7 @@ option(WITH_TOOLS "build with tools" ON)
option(WITH_FUSE_DRIVER "build with FUSE driver" ON) option(WITH_FUSE_DRIVER "build with FUSE driver" ON)
option(WITH_TESTS "build with tests" OFF) option(WITH_TESTS "build with tests" OFF)
option(WITH_BENCHMARKS "build with benchmarks" OFF) option(WITH_BENCHMARKS "build with benchmarks" OFF)
option(WITH_ALL_BENCHMARKS "build with *all* benchmarks" OFF)
option(WITH_FUZZ "build with fuzzing binaries" OFF) option(WITH_FUZZ "build with fuzzing binaries" OFF)
option(WITH_MAN_OPTION "build with --man option" ON) option(WITH_MAN_OPTION "build with --man option" ON)
option(ENABLE_PERFMON "enable performance monitor in all tools" ON) option(ENABLE_PERFMON "enable performance monitor in all tools" ON)
@ -72,6 +73,10 @@ if(USE_JEMALLOC AND USE_MIMALLOC)
message(FATAL_ERROR "USE_JEMALLOC and USE_MIMALLOC are mutually exclusive") message(FATAL_ERROR "USE_JEMALLOC and USE_MIMALLOC are mutually exclusive")
endif() endif()
if(WITH_ALL_BENCHMARKS)
set(WITH_BENCHMARKS ON)
endif()
# Libraries that we can fetch on demand if necessary # Libraries that we can fetch on demand if necessary
# #
# All of these libraries are header-only and not strictly required once # All of these libraries are header-only and not strictly required once
@ -647,6 +652,12 @@ if(WITH_LIBDWARFS AND WITH_BENCHMARKS)
target_link_libraries(dwarfs_benchmark PRIVATE dwarfs_reader dwarfs_writer) target_link_libraries(dwarfs_benchmark PRIVATE dwarfs_reader dwarfs_writer)
list(APPEND BENCHMARK_TARGETS dwarfs_benchmark) list(APPEND BENCHMARK_TARGETS dwarfs_benchmark)
add_executable(segmenter_benchmark test/segmenter_benchmark.cpp)
target_link_libraries(segmenter_benchmark PRIVATE dwarfs_test_helpers benchmark::benchmark)
target_link_libraries(segmenter_benchmark PRIVATE dwarfs_writer)
list(APPEND BENCHMARK_TARGETS segmenter_benchmark)
if(WITH_ALL_BENCHMARKS)
add_executable(multiversioning_benchmark test/multiversioning_benchmark.cpp) add_executable(multiversioning_benchmark test/multiversioning_benchmark.cpp)
target_link_libraries(multiversioning_benchmark PRIVATE benchmark::benchmark) target_link_libraries(multiversioning_benchmark PRIVATE benchmark::benchmark)
target_link_libraries(multiversioning_benchmark PRIVATE dwarfs_writer) target_link_libraries(multiversioning_benchmark PRIVATE dwarfs_writer)
@ -664,11 +675,7 @@ if(WITH_LIBDWARFS AND WITH_BENCHMARKS)
target_link_libraries(nilsimsa_benchmark PRIVATE benchmark::benchmark) target_link_libraries(nilsimsa_benchmark PRIVATE benchmark::benchmark)
target_link_libraries(nilsimsa_benchmark PRIVATE dwarfs_writer) target_link_libraries(nilsimsa_benchmark PRIVATE dwarfs_writer)
list(APPEND BENCHMARK_TARGETS nilsimsa_benchmark) list(APPEND BENCHMARK_TARGETS nilsimsa_benchmark)
endif()
add_executable(segmenter_benchmark test/segmenter_benchmark.cpp)
target_link_libraries(segmenter_benchmark PRIVATE dwarfs_test_helpers benchmark::benchmark)
target_link_libraries(segmenter_benchmark PRIVATE dwarfs_writer)
list(APPEND BENCHMARK_TARGETS segmenter_benchmark)
list(APPEND BINARY_TARGETS ${BENCHMARK_TARGETS}) list(APPEND BINARY_TARGETS ${BENCHMARK_TARGETS})
endif() endif()