| 1 |
cmake_minimum_required(VERSION 3.11...3.14) |
| 2 |
project(JSON_Benchmarks LANGUAGES CXX) |
| 3 |
|
| 4 |
# set compiler flags |
| 5 |
if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang)) |
| 6 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3") |
| 7 |
endif() |
| 8 |
|
| 9 |
# configure Google Benchmarks |
| 10 |
include(FetchContent) |
| 11 |
FetchContent_Declare( |
| 12 |
benchmark |
| 13 |
GIT_REPOSITORY https://github.com/google/benchmark.git |
| 14 |
GIT_TAG origin/main |
| 15 |
GIT_SHALLOW TRUE |
| 16 |
) |
| 17 |
|
| 18 |
FetchContent_GetProperties(benchmark) |
| 19 |
if(NOT benchmark_POPULATED) |
| 20 |
FetchContent_Populate(benchmark) |
| 21 |
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "" FORCE) |
| 22 |
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR}) |
| 23 |
endif() |
| 24 |
|
| 25 |
# download test data |
| 26 |
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake ${CMAKE_MODULE_PATH}) |
| 27 |
include(download_test_data) |
| 28 |
|
| 29 |
# benchmark binary |
| 30 |
add_executable(json_benchmarks src/benchmarks.cpp) |
| 31 |
target_compile_features(json_benchmarks PRIVATE cxx_std_11) |
| 32 |
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT}) |
| 33 |
add_dependencies(json_benchmarks download_test_data) |
| 34 |
target_include_directories(json_benchmarks PRIVATE ${CMAKE_SOURCE_DIR}/../../single_include ${CMAKE_BINARY_DIR}/include) |