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