简体   繁体   English

QtCreator Cmake C ++ 17功能

[英]QtCreator Cmake C++17 Features

So here I am, compiling my CMake-based C++ Projects in my terminal like there's not tomorrow with gcc-7.2.0 on Xubuntu 16.04 (via ppa) 所以我在这里,在终端中编译基于CMake的C ++项目,就像明天在Xubuntu 16.04上使用gcc-7.2.0一样(通过ppa)

Everything works fine and the new features add considerable value to my codebase. 一切正常,新功能为我的代码库增加了可观的价值。

However, trying to compile the very same project in qtcreator with the same compiler yields me errors like the following 但是,尝试使用相同的编译器在qtcreator中编译非常相同的项目会产生类似以下的错误

 : error: expected ')' before ';' token if (auto event = events_.find(eventName); event == end(events_)) { ^ : error: 'else' without a previous 'if' } else { ^ 

if trying to compile initializer-ifs. 如果尝试编译initializer-ifs。 I tried to manually pick gcc-7 in the build&run section in qtCreators options but without success. 我尝试在qtCreators选项的“构建和运行”部分中手动选择gcc-7,但未成功。 So my question is this: 所以我的问题是这样的:

What do I have to adjust in the IDE to make it conform to this latest standard? 我必须在IDE中进行哪些调整以使其符合最新标准?

If you're compiling Cmake projects in Qt creator, just be sure there is a line like this in your CMakeLists.txt: 如果要在Qt Creator中编译Cmake项目,只需确保在CMakeLists.txt中有这样一行:

set(CMAKE_CXX_STANDARD 17)

To use gcc-7.2.0, be sure it is listed in the Compilers tab of the Build & Run section in Tools/Option . 要使用gcc-7.2.0,请确保在“ 工具/选项 的“ 构建和运行”部分的“ 编译器”选项卡中列出了它。 Then, in Kits tab, select the kit you configured your project with, and select gcc-7.2.0 as the the kit's compiler. 然后,在“ 工具包”选项卡中,选择用于配置项目的工具包,然后选择gcc-7.2.0作为工具包的编译器。

If you're using qmake, instead, add this line to your pro file: 如果您使用的是qmake,请将此行添加到您的pro文件中:

QMAKE_CXXFLAGS += -std=c++17

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM