1

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:

image description

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?

Community
  • 1
  • 1
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

1 Answers1

3

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:

image description

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
  • Glad I could help. Note that there's one caveat which occurs when C files are included and compiled via C compiler. I assume `QMAKE_CFLAGS` is the correct variable for those but I did not finish my research on that topic. – Tomáš Zato Apr 10 '16 at 13:14
  • Thanks for the caveat - my case is for headers only where libraries are linked (or are header-only libraries). – sage Apr 11 '16 at 21:10