From 4fd9b52fc2ff796e2dcf207387f7a3b217d5e314 Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Wed, 16 Jan 2019 08:21:49 -0500 Subject: [PATCH] Use C++11 features supported by CMake 3.1. --- CMakeLists.txt | 6 +++++- benchmarks/CMakeLists.txt | 2 +- test/CMakeLists.txt | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da6f08e7..43369782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,11 @@ endif() ## add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE) add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME}) -target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11) +if (${CMAKE_VERSION} VERSION_LESS "3.8.0") + target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_range_for) +else() + target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11) +endif() target_include_directories( ${NLOHMANN_JSON_TARGET_NAME} diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 06da16e4..953b1cb8 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(JSON_Benchmarks LANGUAGES CXX) # set compiler flags diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 04acdaab..5f253bff 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -64,7 +64,11 @@ set_target_properties(catch_main PROPERTIES COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -target_compile_features(catch_main PUBLIC cxx_std_11) +if (${CMAKE_VERSION} VERSION_LESS "3.8.0") + target_compile_features(catch_main PUBLIC cxx_range_for) +else() + target_compile_features(catch_main PUBLIC cxx_std_11) +endif() target_include_directories(catch_main PRIVATE "thirdparty/catch") # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake