From de022e8908cc5b3a6e0f179a81482fad4cfb6072 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 Dec 2014 14:06:43 -0500 Subject: [PATCH] Add options to build CMake without latest language dialects Set CMAKE_C_STANDARD and CMAKE_CXX_STANDARD only if they are not already defined. This will allow users to add the settings with different values to their local cache (e.g. on the command line). --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad3bb9734..1812b2773 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,12 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") endif() # Use most-recent available language dialects with GNU and Clang -set(CMAKE_C_STANDARD 11) -set(CMAKE_CXX_STANDARD 14) +if(NOT DEFINED CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) +endif() +if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() # option to set the internal encoding of CMake to UTF-8 option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF)