From 3d76e980cc81e3c371b6ce4e5d06e079369491cb Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 1 Mar 2014 07:42:32 -0700 Subject: [PATCH] Attempt to detect if g++ is old and we should use --c++0x --- CMakeLists.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04be8b7..acf6de8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,11 +70,25 @@ else(READLINE_LIBRARY) set (READLINE_FLAG ) endif(READLINE_LIBRARY) + +if (CMAKE_COMPILER_IS_GNUCC) + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION) + + if (GCC_VERSION VERSION_LESS 4.8) + SET(CPP11_FLAG "-std=c++0x") + else() + SET(CPP11_FLAG "-std=c++11") + endif() +else() + SET(CPP11_FLAG "-std=c++11") +endif() + if(MSVC) add_definitions(/W4) add_definitions(/bigobj) else() - add_definitions(-Wall -Wextra -Wshadow -pedantic -std=c++11) + add_definitions(-Wall -Wextra -Wshadow -pedantic ${CPP11_FLAG}) if (APPLE) add_definitions(-Wno-sign-compare) @@ -87,9 +101,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if (USE_LIBCXX) add_definitions(-stdlib=libc++) - set (EXTRA_LINKER_FLAGS -std=c++11 -stdlib=libc++) + set (EXTRA_LINKER_FLAGS ${CPP11_FLAG}-stdlib=libc++) else () - set (EXTRA_LINKER_FLAGS -std=c++11 ) + set (EXTRA_LINKER_FLAGS ${CPP11_FLAG} ) endif() else() set (EXTRA_LINKER_FLAGS )