Important: Please read the Qt Code of Conduct -

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 $$.

  • 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,

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


    Notice two $$ before (AND…

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

Log in to reply