[英]Gradle with C++: How to change compiler options?
I'm starting to work with Gradle and have just built a couple things. 我开始与Gradle合作,并完成了一些工作。 The build generated the file "options.txt":
构建生成文件“ options.txt”:
-x
c++
-c
-I
/path/to/project/src/main/headers
-I
/path/to/project/src/hello/headers
-m64
That's cool that they choose compiler options for me but for example I'd like to compile my stuff with -std=c++17 and -Wall and -Wextra. 他们为我选择编译器选项很酷,但是例如,我想使用-std = c ++ 17以及-Wall和-Wextra来编译我的东西。 So how can I add these flags to the g++ options?
那么如何将这些标志添加到g ++选项中呢?
Just add the following inside 'model' in build.gradle: 只需在build.gradle中的“模型”内部添加以下内容:
toolChains {
gcc(Gcc) {
eachPlatform {
cppCompiler.withArguments { args ->
args << "-std=c++17"
}
cppCompiler.withArguments { args ->
args << "-Wall"
}
cppCompiler.withArguments { args ->
args << "-Wextra"
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.