问题描述
我想要禁止外部程式库的警告,可以我可以使用这样的:
isCompiling {
QMAKE_CXXFLAGS + = -isystem ../libs/boost159/
} else {
INCLUDEPATH + = ../libs/boost159/ $为了使QtCreator的解析不会失败,但在编译时, b
$ b
$ b 。任何想法?
如何制作一个条件表达式,只有在QtCreator解析项目文件时才触发/ / p>
我发现了解决方案。您需要使用 qmake
其他参数,并指定您选择的变量,然后测试是否已定义。由于QtCreator不知道这些参数,它不会执行用于编译的块:
#这个变量被设置作为CONFIG + = compiling
#在qmake命令行参数中完成赋值
编译{
#此块在实际编译期间生效
QMAKE_CXXFLAGS + = -isystem .. / libs / boost159 / -isystem ../libs/openssl/include
} else {
#这个块被QtCreator和其他没有定义CONFIG编译的工具看到
INCLUDEPATH + = ../libs/boost159/../libs/openssl/include
}
然后必须在项目管理中进行设置。不要忘记为发布和调试设置:
I wanted to suppress warning from external libraries which can be done by marking them as system libraries. I figured out this is how to do it in .pro
QtCreator project file:
QMAKE_CXXFLAGS += -isystem ../libs/boost159/
The problem is that QtCreator relies on the INCLUDEPATH
setting, expects this:
INCLUDEPATH += ../libs/boost159/
If I remove it, the QtCreator no longer can find boost libraries:
I originally wanted to report this as a bug but after some reports I no longer believe the QtCreator developers will ever consider fixing this. Instead, I came here for a workaround.
Because qmake has conditional statements I could make use of something like this:
isCompiling {
QMAKE_CXXFLAGS += -isystem ../libs/boost159/
} else {
INCLUDEPATH += ../libs/boost159/
}
So that QtCreator's parsing would not fail but upon compile, isystem
would be used. Any ideas?
Exoplicitly: How can I make a conditional expression that will only trigger/not trigger when QtCreator is parsing the project file?
I have discovered the solution. You need to use qmake
additional arguments and specify a variable of your choice, then test if it's defined. Since QtCreator doesn't know about these parameters, it won't execute the block intended for compilation:
# This variable is set as "CONFIG += compiling"
# The assignment is done in qmake command line argument
compiling {
# This block takes effect during real compilation
QMAKE_CXXFLAGS += -isystem ../libs/boost159/ -isystem ../libs/openssl/include
} else {
# This block is seen by QtCreator and other tools that do not have 'CONFIG compiling' defined
INCLUDEPATH += ../libs/boost159/ ../libs/openssl/include
}
The setting then must be done in project management. Don't forget to set it for both release and debug:
这篇关于当我使用-isystem标志而不是INCLUDEPATH时,QtCreator的代码检查器会断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!