#error This file requires compiler and library support for the ISO C++ 2011错误解决办法
在CMakeLists.txt添加:
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS “
C
M
A
K
E
C
X
X
F
L
A
G
S
−
s
t
d
=
c
+
+
11
"
)
e
l
s
e
i
f
(
C
O
M
P
I
L
E
R
S
U
P
P
O
R
T
S
C
X
X
0
X
)
s
e
t
(
C
M
A
K
E
C
X
X
F
L
A
G
S
"
{CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "
CMAKECXXFLAGS−std=c++11")elseif(COMPILERSUPPORTSCXX0X)set(CMAKECXXFLAGS"{CMAKE_CXX_FLAGS} -std=c++0x”)
else()
message(STATUS “The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.”)
endif()
备注个人学习:
cmake .
make
g++ -std=c++11 CheckOnFive.cpp
./a.out