1 message ("-- Configuring C++11")
2 message ("-- System: ${CMAKE_SYSTEM_NAME}")
4 include (CheckCXXCompilerFlag)
6 # NOTE: Phase out -std=gnu++0x and --std=c++0x as soon as realistically possible.
7 CHECK_CXX_COMPILER_FLAG("-std=c++11" _HAS_CXX11)
8 CHECK_CXX_COMPILER_FLAG("-std=c++0x" _HAS_CXX0X)
9 CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" _HAS_GNU0X)
12 set (_CXX11_FLAGS "-std=c++11")
14 message (WARNING "Enabling -std=c++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
15 set (_CXX11_FLAGS "-std=c++0x")
17 message (WARNING "Enabling -std=gnu++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
18 set (_CXX11_FLAGS "-std=gnu++0x")
20 message (FATAL_ERROR "C++11 support missing. Try upgrading your C++ compiler.")
23 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
25 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
27 set (_CXX11_FLAGS "${_CXX11_FLAGS} -stdlib=libc++")
28 elseif (${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD")
30 elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
32 elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
34 elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
36 elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
38 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "GNU")
40 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
42 # NOTE: Not setting -std=gnu++0x leads to compile errors even with
43 # GCC 4.8.3, and debugging those leads to insanity. Adding this
44 # workaround instead of fixing Cygwin.
45 set (_CXX11_FLAGS "-std=gnu++0x")
46 else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
48 endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
50 set (CMAKE_CXX_FLAGS "${_CXX11_FLAGS} ${CMAKE_CXX_FLAGS}")
51 set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}")