Problem with qmake equals()/isEqual()



  • Hi,

    I have a problem using the equals()/isEqual() function.
    I must not have understood it well, because after seeing that it behaved differently than I thought, I inserted the following code into my .pro to test it out:
    @
    equals(MY_ENV_VAR,foobar) {
    system(echo "OK 1")
    }
    equals($MY_ENV_VAR,foobar) {
    system(echo "OK 2")
    }
    equals($$MY_ENV_VAR,foobar) {
    system(echo "OK 3")
    }
    system(echo "var = $MY_ENV_VAR")
    @

    And after "export MY_ENV_VAR=foobar", I run make distclean & re-run the qmake and make files... and the result is, that all 3 tests fail, but it prints out "var = foobar" correctly.

    What am I doing wrong here?



  • To use environment variable you have to use $$() instead of $$.
    Try:
    @error($$(PATH))@



  • Hi, p-himik;

    In fact, that was my first try, after reading the manual. But I thought that it didn't work.

    The problem was, though, that equals can not take an argument like: $$(...)

    So this is not possible:

    @
    equals($$(MY_ENV_VAR), foo)
    @

    On the advice of peppe, I got it working by storing the value in another qmake variable, and then doing the comparison on that second variable instead of the original.

    Thank you for your help,
    Pierre



  • This is just clarification to old post about comparing environment variables within qmake (still being viewed), and also about cheking android architecture:

    MY_TMP = $ $(ANDROID_NDK_TOOLCHAIN_PREFIX)
    equals(MY_TMP,x86){
    

    Notice two $$ before (AND…

    [edit: added space between the two $ signs, to be removed in real code. SGaist]


Log in to reply
 

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