added compiler (and it's version) detection

This should fix problems with different flags for c++11 across different gcc
versions. Should compile on Clang and gcc >= 4.6. Lower versions of gcc are
untested. I don't even know wheteher they support c++11 (gcc 4.2.1 on OpenBSD
5.7 does not).
This commit is contained in:
Pawel "l0ner" Soltys 2015-01-17 16:30:31 +01:00
parent 7151b70c70
commit 2cc9efb187

@ -49,9 +49,24 @@ endif()
# set common source files # set common source files
SET( COMMON_SOURCES "tmux-mem-cpu-load.cpp" "graph.cc" "argParse/argParse.cc" ) SET( COMMON_SOURCES "tmux-mem-cpu-load.cpp" "graph.cc" "argParse/argParse.cc" )
# compiler flags # compiler flags
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " ) if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAD ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_EQUAL 4.6)
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++0x " )
elseif (GCC_VERSION GREATER 4.6)
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " )
else()
message( FATAL_ERROR "You need gcc version >= 4.6")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET( GCC_COVERAGE_COMPILE_FLAGS "-std=c++11 " )
else()
message( WARNING "Untested compiler detected. You may need to set c++11
support manually through CMakeList.txt file")
SET( GCC_COVERAGE_COMPILE_FLAGS "" )
endif()
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" ) SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
# add binary tree so we find version.h # add binary tree so we find version.h