2021-03-24 09:15:18 +03:00
|
|
|
cmake_minimum_required(VERSION 3.11)
|
2018-01-18 23:57:21 +03:00
|
|
|
project(JSON_Benchmarks LANGUAGES CXX)
|
|
|
|
|
|
|
|
# set compiler flags
|
|
|
|
if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang))
|
2021-03-24 09:15:18 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3")
|
2018-01-18 23:57:21 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# configure Google Benchmarks
|
2021-03-24 09:15:18 +03:00
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
benchmark
|
|
|
|
GIT_REPOSITORY https://github.com/google/benchmark.git
|
2021-06-01 15:17:53 +03:00
|
|
|
GIT_TAG origin/main
|
2021-03-24 09:15:18 +03:00
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
)
|
2018-01-18 23:57:21 +03:00
|
|
|
|
2021-03-24 09:15:18 +03:00
|
|
|
FetchContent_GetProperties(benchmark)
|
|
|
|
if(NOT benchmark_POPULATED)
|
|
|
|
FetchContent_Populate(benchmark)
|
|
|
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "" FORCE)
|
|
|
|
add_subdirectory(${benchmark_SOURCE_DIR} ${benchmark_BINARY_DIR})
|
|
|
|
endif()
|
2018-01-18 23:57:21 +03:00
|
|
|
|
2020-05-01 21:59:47 +03:00
|
|
|
# download test data
|
2022-03-24 09:54:07 +03:00
|
|
|
include(download_test_data)
|
2018-01-18 23:57:21 +03:00
|
|
|
|
|
|
|
# benchmark binary
|
|
|
|
add_executable(json_benchmarks src/benchmarks.cpp)
|
2018-03-27 19:51:30 +03:00
|
|
|
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
|
2018-01-18 23:57:21 +03:00
|
|
|
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
|
2020-05-01 21:59:47 +03:00
|
|
|
add_dependencies(json_benchmarks download_test_data)
|
2021-03-24 09:15:18 +03:00
|
|
|
target_include_directories(json_benchmarks PRIVATE ${CMAKE_SOURCE_DIR}/../single_include ${CMAKE_BINARY_DIR}/include)
|