Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple conditionals in QMake pro file
Forum Updated to NodeBB v4.3 + New Features

Multiple conditionals in QMake pro file

Scheduled Pinned Locked Moved Solved General and Desktop
qmakepro
5 Posts 2 Posters 3.3k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    nim108
    wrote on last edited by nim108
    #1

    I have this code that copies additional folders from my build directory to the output:

        copydata.commands += mkdir -p $$OUT_PWD/dir1 ;
        copydata.commands += mkdir -p $$OUT_PWD/dir2 ;
        copydata.commands += echo "Copying additional files..." ;
        copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ;
        copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ;
        first.depends = $(first) copydata
        export(first.depends)
        export(copydata.commands)
        QMAKE_EXTRA_TARGETS += first copydata
    

    I only want this to run if dir1 OR dir2 don't exist OR are empty as they take time to copy on every compile. I've tried every combination of this condition (along with isEmpty) to no avail:

    !exists( $$OUT_PWD/dir1 ) || !exists( $$OUT_PWD/dir2 ){
    

    What's the proper syntax to combine conditions or is that not allowed? Just wondering what the best way to do this is ... I know I can always hack it to work by nesting these conditions or using an extra variable but it should work just with the built in isEmpty() and exists() functions. Thanks.

    kshegunovK 1 Reply Last reply
    0
    • N nim108

      I have this code that copies additional folders from my build directory to the output:

          copydata.commands += mkdir -p $$OUT_PWD/dir1 ;
          copydata.commands += mkdir -p $$OUT_PWD/dir2 ;
          copydata.commands += echo "Copying additional files..." ;
          copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ;
          copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ;
          first.depends = $(first) copydata
          export(first.depends)
          export(copydata.commands)
          QMAKE_EXTRA_TARGETS += first copydata
      

      I only want this to run if dir1 OR dir2 don't exist OR are empty as they take time to copy on every compile. I've tried every combination of this condition (along with isEmpty) to no avail:

      !exists( $$OUT_PWD/dir1 ) || !exists( $$OUT_PWD/dir2 ){
      

      What's the proper syntax to combine conditions or is that not allowed? Just wondering what the best way to do this is ... I know I can always hack it to work by nesting these conditions or using an extra variable but it should work just with the built in isEmpty() and exists() functions. Thanks.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      http://doc.qt.io/qt-5/qmake-language.html#scopes-and-conditions

      use the pipe - |.

      Read and abide by the Qt Code of Conduct

      N 1 Reply Last reply
      2
      • kshegunovK kshegunov

        http://doc.qt.io/qt-5/qmake-language.html#scopes-and-conditions

        use the pipe - |.

        N Offline
        N Offline
        nim108
        wrote on last edited by nim108
        #3

        @kshegunov

        I've tried every variation of the conditionals with the pipe operator as well.

        !exists( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 )
        !exists(( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 ))
        !exists(( $$OUT_PWD/dir1 ) | ( $$OUT_PWD/dir2 ))
        

        None of these work the way it's supposed to. It will ALWAYS copy the files over. Any suggestions?

        kshegunovK 1 Reply Last reply
        0
        • N nim108

          @kshegunov

          I've tried every variation of the conditionals with the pipe operator as well.

          !exists( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 )
          !exists(( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 ))
          !exists(( $$OUT_PWD/dir1 ) | ( $$OUT_PWD/dir2 ))
          

          None of these work the way it's supposed to. It will ALWAYS copy the files over. Any suggestions?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4
          if(!exists( $$OUT_PWD/dir1 )|!exists( $$OUT_PWD/dir2 )) {
              // ...
          }
          

          I got this directly from the qmake manual, by the way.
          http://doc.qt.io/qt-5/qmake-test-function-reference.html#if-condition

          Read and abide by the Qt Code of Conduct

          N 1 Reply Last reply
          2
          • kshegunovK kshegunov
            if(!exists( $$OUT_PWD/dir1 )|!exists( $$OUT_PWD/dir2 )) {
                // ...
            }
            

            I got this directly from the qmake manual, by the way.
            http://doc.qt.io/qt-5/qmake-test-function-reference.html#if-condition

            N Offline
            N Offline
            nim108
            wrote on last edited by
            #5

            @kshegunov

            I've tried that too ... but I see what I'm doing wrong. I guess you have to manually run qmake every time you delete the folder to test it or else it won't update the condition. I just kept rebuilding it, which didn't work. Thanks. Guess one of my previous conditions would have worked for this as well.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved