Congratulations to our 2022 Qt Champions!

VC++ Compiler Flags Per-Profile

  • Is there a way to add C++ compiler flags for just one profile? For example, I want to have a "Portable" install option that uses a local .ini file instead of the Windows registry. I created a profile called "PORTABLE" that is based on "RELEASE." I need to pass the flag /DPORTABLE to cl.exe so that my preprocessor directives catch that this is a portable install and use the right logic.

    I think I could use


    in my .pro file, but that would pass it to every profile. I could create a separate .pro for the portable install, but that seems unelegant and like overkill. I assume that it's something that needs to go in .pro.user, or that I can set in the GUI for the PORTABLE profile, but I don't see where to put it. Any suggestions?


  • Not sure if it works (and if I understand your question correctly), but have you tried this?

    win32: {
        CONFIG(debug, debug|release):            ///whatever, if you need it
            else:CONFIG(release, release|debug):  QMAKE_CXXFLAGS += /DPORTABLE

Log in to reply