mirror of
https://github.com/nlohmann/json.git
synced 2024-08-21 20:42:29 +02:00
Starting with CMake 3.27, deprecation warnings are issued when asking for policy settings for CMake 3.4 or earlier. The cmake_minimum_required() command accepts a version range, which allows NEW policy settings up to the upper end of that range to be used, but without raising the minimum CMake version above the bottom of that range. This means NEW policy settings will be used where available, without requiring them. This change updates the project's cmake_minimum_required() calls to use a version range to extend the upper policy version to 3.14 where it wasn't already at that version or higher. This prevents the deprecation warning from CMake 3.27, and gives breathing space before a future CMake release will start issuing similar deprecation warnings again.
35 lines
1.2 KiB
CMake
35 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.11...3.14)
|
|
project(JSON_Benchmarks LANGUAGES CXX)
|
|
|
|
# set compiler flags
|
|
if((CMAKE_CXX_COMPILER_ID MATCHES GNU) OR (CMAKE_CXX_COMPILER_ID MATCHES Clang))
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -DNDEBUG -O3")
|
|
endif()
|
|
|
|
# configure Google Benchmarks
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
benchmark
|
|
GIT_REPOSITORY https://github.com/google/benchmark.git
|
|
GIT_TAG origin/main
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
|
|
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()
|
|
|
|
# download test data
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake ${CMAKE_MODULE_PATH})
|
|
include(download_test_data)
|
|
|
|
# benchmark binary
|
|
add_executable(json_benchmarks src/benchmarks.cpp)
|
|
target_compile_features(json_benchmarks PRIVATE cxx_std_11)
|
|
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
|
|
add_dependencies(json_benchmarks download_test_data)
|
|
target_include_directories(json_benchmarks PRIVATE ${CMAKE_SOURCE_DIR}/../../single_include ${CMAKE_BINARY_DIR}/include)
|