[solved] qmake Detect enviroment variable



  • Hello,

    Trying to write some code that reads a environment variable and adds some defines. not quite sure what I am doing wrong here:

    In the project file:
    equals($$(XDG_CURRENT_DESKTOP),"Unity"){
    DEFINES+= ISUNITY
    }
    contains($$(XDG_CURRENT_DESKTOP),"Unity"){
    DEFINES+= ISUNITY
    }

    in the code file:
    #ifdef ISUNITY
    // <-- this should run on Ubuntu / Linux
    #else
    // <-- It is always running this code, even when the environment variable is in place and should run the lines above
    #endif


  • Lifetime Qt Champion

    Hi,

    equals takes a variable name so you might have to do it in two steps

    @
    CURRENT_DESKTOP = $$(XDG_CURRENT_DESTKOP)
    equals(CURRENT_DESTKOP, "Unity") {
    DEFINES += IS_UNITY
    }
    @

    same applies for contains.

    Hope it helps



  • Awesome thanks!


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working as you want now, please also update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.