From 19b448e09e34e8bdabb6767d7ca4a6fad125e4c4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 15 Feb 2017 03:18:19 -0700 Subject: [PATCH] CMake: Update master CMakeLists to compile for C++11 --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e144257a37..558dcbff1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,20 @@ set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) # Must go before project() below project(Panda3D) enable_testing() +# Panda3D is now a C++11 project. Newer versions of CMake support this out of +# the box; for older versions we take a shot in the dark: +if(CMAKE_VERSION VERSION_LESS "3.1") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) + if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + endif() +else() + set(CMAKE_CXX_STANDARD 11) +endif() + # Add generic modules to cmake module path, # and add Panda3D specific modules to cmake module path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")