From 66aa6947b4a0c04875a1652d8a1a86429681d7ce Mon Sep 17 00:00:00 2001 From: Mathnerd314 Date: Mon, 4 Aug 2014 04:23:40 +0200 Subject: [PATCH] Fix C++0x flags for clang --- CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4264610e3..d4b606dc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,8 +226,23 @@ ENDIF(COMPILE_AMALGATION) OPTION(WERROR "Stop on first compiler warning" OFF) OPTION(WARNINGS "Enable long list of warnings for compiler to check" OFF) + +# http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/ +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(COMPILER_SUPPORTS_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) + if(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + else(COMPILER_SUPPORTS_CXX0X) + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif(COMPILER_SUPPORTS_CXX0X) +endif(COMPILER_SUPPORTS_CXX11) + + IF(CMAKE_COMPILER_IS_GNUCC) - SET(CMAKE_CXX_FLAGS "-std=c++0x") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug flags") SET(CMAKE_CXX_FLAGS_PROFILE "-pg" CACHE STRING "Profile flags") -- 2.11.0