Ine8b6b7ad, we relaxed the cmake version check down to 3.1, the first version to expose target_compile_features(). However, an error while testing that change improperly concluded that the change was OK. While target_compile_features() was indeed intriduced in cmake 3.1, the actual feature we use it to test, cxx_std_11, was really introduced only with cmake-3.8, which explained the actual version that was requested beforee8b6b7ad. As Patrick noted, however, we can still convince cmake-3.1 to test for C++11, by testing for an actual feature introduced in C++11, like testing for cxx_range_for, which will instruct cmake to set the appropriate C++11 options for the current compiler, which for gcc would be adding -std=gnu++11. Reported-by: Patrick Boettcher <patrick.boettcher@posteo.de> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
28 lines
1.0 KiB
CMake
28 lines
1.0 KiB
CMake
cmake_minimum_required(VERSION 3.1)
|
|
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
|
|
set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "" FORCE)
|
|
add_subdirectory(thirdparty/benchmark)
|
|
|
|
# header directories
|
|
include_directories(thirdparty)
|
|
include_directories(${CMAKE_SOURCE_DIR}/../single_include)
|
|
|
|
# copy test files to build folder
|
|
file(COPY ${CMAKE_SOURCE_DIR}/data DESTINATION .)
|
|
file(COPY ${CMAKE_SOURCE_DIR}/../test/data/regression/floats.json
|
|
${CMAKE_SOURCE_DIR}/../test/data/regression/unsigned_ints.json
|
|
${CMAKE_SOURCE_DIR}/../test/data/regression/signed_ints.json
|
|
DESTINATION data/numbers)
|
|
|
|
# benchmark binary
|
|
add_executable(json_benchmarks src/benchmarks.cpp)
|
|
target_compile_features(json_benchmarks PRIVATE cxx_range_for)
|
|
target_link_libraries(json_benchmarks benchmark ${CMAKE_THREAD_LIBS_INIT})
|