Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Problem with qmake equals()/isEqual()

    Tools
    3
    4
    6000
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pierrevr last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • P
        p-himik last edited by

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

        1 Reply Last reply Reply Quote 0
        • P
          pierrevr last edited by

          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

          1 Reply Last reply Reply Quote 0
          • Pekka
            Pekka last edited by SGaist

            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]

            1 Reply Last reply Reply Quote 0
            • First post
              Last post