Qt World Summit: Submit your Presentation

qmake CONFIG variables with values

  • Is it possible to add to CONFIG variables with values?

    Eg something like

    CONFIG += FOO=1
    FOO==1 {
       message("foo is 1")
    FOO==2 {
       message("foo is 2")

    When doing so, I get the error Excess closing brace.

    Obviously, I could use CONFIG += FOO1 and FOO1 {...} but I want to make sure that the values of FOO are exclusive and that

    CONFIG += FOO=1
    CONFIG += FOO=2

    results in FOO==2.

    Is this possible with qmake?

  • Lifetime Qt Champion


    AFAIK, no.

    Can you explain what you are trying to achieve using CONFIG like that ?

    Your code does not look like it needs to have that stored in CONFIG.

  • I want to build different assets from a single .pro file (so I want to set different SOURCES, INCLUDES, ...). CONFIG seemed to be the most 'logical' way to me.

    However, I noticed that I can achieve what I want using the following snippet

    FOO = 1
    FOO = 2  
    contains (FOO, 1) {
        message("FOO is 1")
    contains (FOO, 2) {
        message("FOO is 2")

  • Lifetime Qt Champion

    CONFIG is rather to enable features.

    If you want control like that, your current solution is better.

Log in to reply