From c09917c6a75c720438d723f31f7b27940f4fa0bc Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 12 Feb 2018 10:56:10 +0000 Subject: [PATCH] Optionally use newer cmake features. So we can keep supporting cmake 2.8.12, which is the version on ubuntu trusty. --- CMakeLists.txt | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6d9e2a2..8bba3519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ # ################################################################################ -cmake_minimum_required(VERSION 3.1.0) -cmake_policy(VERSION 3.1.0) +cmake_minimum_required(VERSION 2.8.12) +cmake_policy(VERSION 2.8.12) project(toxcore) set(CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake) @@ -66,14 +66,19 @@ enable_testing() set(CMAKE_MACOSX_RPATH ON) -# Set standard version for compiler. -set(CMAKE_C_STANDARD 99) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_C_EXTENSIONS OFF) -set(CMAKE_CXX_EXTENSIONS OFF) +if(${CMAKE_VERSION} VERSION_LESS "3.1.0") + add_cflag("-std=c99") + add_cxxflag("-std=c++11") +else() + # Set standard version for compiler. + set(CMAKE_C_STANDARD 99) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_C_EXTENSIONS OFF) + set(CMAKE_CXX_EXTENSIONS OFF) -message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}") -message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") + message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}") + message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}") +endif() if(NOT MSVC) # Warn on non-ISO C.