2023-09-25 15:31:26 +08:00
|
|
|
cmake_minimum_required(VERSION 3.11...3.14)
|
2018-01-19 04:57:21 +08: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 14:15:18 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3")
|
2018-01-19 04:57:21 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# configure Google Benchmarks
|
2021-03-24 14:15:18 +08:00
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
benchmark
|
|
|
|
GIT_REPOSITORY https://github.com/google/benchmark.git
|
2021-06-01 20:17:53 +08:00
|
|
|
GIT_TAG origin/main
|
2021-03-24 14:15:18 +08:00
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
)
|
2018-01-19 04:57:21 +08:00
|
|
|
|
2021-03-24 14:15:18 +08: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-19 04:57:21 +08:00
|
|
|
|
2020-05-02 02:59:47 +08:00
|
|
|
# download test data
|
2022-05-01 15:41:50 +08:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake ${CMAKE_MODULE_PATH})
|
2022-03-24 14:54:07 +08:00
|
|
|
include(download_test_data)
|
2018-01-19 04:57:21 +08:00
|
|
|
|
|
|
|
# benchmark binary
|
|
|
|
add_executable(json_benchmarks src/benchmarks.cpp)
|
2018-03-28 00:51:30 +08:00
|
|
|
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
|
2018-01-19 04:57:21 +08:00
|
|
|
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
|
2020-05-02 02:59:47 +08:00
|
|
|
add_dependencies(json_benchmarks download_test_data)
|
2022-05-01 15:41:50 +08:00
|
|
|
target_include_directories(json_benchmarks PRIVATE ${CMAKE_SOURCE_DIR}/../../single_include ${CMAKE_BINARY_DIR}/include)
|