How to detect Qt Creator's target (debug/release) (Visual Studio)

后端 未结 1 1907
余生分开走
余生分开走 2021-01-18 17:25

So I use qmake to create my program, but I\'m always having a conflict between my debug and release boost libraries with the message:

libboost_syste         


        
相关标签:
1条回答
  • 2021-01-18 17:31

    The answer is I think in Qt project org faq 355

    If you always accept the name Qt Creator suggests for your build you can use the following simple solution in your pro files that in my case (Qt 5.5) works for Linux, Mac and Windows:

    # to distinguish between debug and release executable as target
    # we define the variables releaseExec and debugExec
    # this only works if the $$OUT_PWD has "Release" in its name
    BDIR = $$OUT_PWD
    BDIR_STRIPPED = $$replace(BDIR,Release,)
    equals (BDIR,$$BDIR_STRIPPED): CONFIG+= debugExec
    else: CONFIG+= releaseExec
    

    We used the variables releaseExec and debugExec to avoid name collisions with Qt CONFIG variables.

    You can now use the switch statements:

    releaseExec: warning ("this is a release build")
    debugExec: warning ("this is a debug build")
    
    0 讨论(0)
提交回复
热议问题