C++11 设置g++;模式转换为C++;11

C++11 设置g++;模式转换为C++;11,c++11,cmake,g++,C++11,Cmake,G++,我正在尝试构建cmake源代码,它需要C++11。 构建停止,显然投诉是没有检测到C++11。g++模式实际上设置为-std=gnu++17 这是控制台日志的一部分 --------------------------------------------- CMake 3.18.20200919, Copyright 2000-2020 Kitware, Inc. and Contributors Found GNU toolchain C compiler on this system is:

我正在尝试构建cmake源代码,它需要C++11。 构建停止,显然投诉是没有检测到C++11。g++模式实际上设置为-std=gnu++17

这是控制台日志的一部分

---------------------------------------------
CMake 3.18.20200919, Copyright 2000-2020 Kitware, Inc. and Contributors
Found GNU toolchain
C compiler on this system is: gcc   
C++ compiler on this system is: g++  -std=gnu++17  
Makefile processor on this system is: make
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
g++  -std=gnu++17      -DCMAKE_BOOTSTRAP    -DCMake_HAVE_CXX_MAKE_UNIQUE=1  -c $HOME/Apps/CMake-master/Source/cmAddCustomCommandCommand.cxx -o cmAddCustomCommandCommand.o
环顾网络,我注意到C++11仅在gcc版本4.6之后才可用。 我检查了我的版本,它似乎在上面

g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
我知道-std=c++11标志用于启用g++中的c++11功能,但我似乎不知道在这种情况下我在做什么。 我尝试编辑CompileFlags.cmake文件,但没有发生任何更改

我找到了指向我正在使用的cmake源的点。 上面说

bootstrap: Require compiler mode aware of C++11

Some compilers have enough features enabled in their default modes to
pass our simple C++11 unique_ptr check but do not enable enough to build
CMake.  Poison this case so that we choose one of the explicit `-std=`
options for such compilers.
我不知道那到底是什么意思

如何将g++模式更改为C++11,以便在运行bootstrap命令时使用C++11?
或者,换句话说,如何将std更改为指向C++11(-std=C++11)?

首先,您的主机PC中安装了g++5.4.0版,这很好,因为这意味着它也支持您想要使用的C++11。 要设置它,您可以在CMakeList.txt文件中定义它:

这应该能奏效。 还请检查文档:


通常,我建议您使用编译器支持的最新标准(),因为您还将获得该标准中引入的最新特性。例外情况是,如果您使用的是旧代码。

欢迎使用堆栈溢出!你对这个问题的描述相当。。。因为能够帮助你而含糊不清。请参考并回答相应的问题(至少包括您收到的确切错误消息)。如果您是Ubuntu,使用apt安装CMake并从源代码构建它会更容易。仅当您首先没有CMake时才需要引导。另外,如果引导不起作用,那么向kitware报告bug报告可能是个好主意。谢谢你的提示。我甚至没有考虑使用cmake,只是按照页面上的说明操作。我想我会尝试使用cmake@dboy你能给你的帖子一点细节吗,因为这个集合(CMAKE_CXX_STANDARD 11)已经设置好使用,但只有在一些条件不满足的情况下。我不知道我是否应该取消这些条件。@fdk cmake是轻而易举的事。这就是我想看到的。没有错误的构建。
bootstrap: Require compiler mode aware of C++11

Some compilers have enough features enabled in their default modes to
pass our simple C++11 unique_ptr check but do not enable enough to build
CMake.  Poison this case so that we choose one of the explicit `-std=`
options for such compilers.
set (CMAKE_CXX_STANDARD 11)