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.4k 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 4 Nov 2017, 22:18 last edited by nim108 11 Apr 2017, 22:41
    #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.

    K 1 Reply Last reply 4 Nov 2017, 23:11
    0
    • N nim108
      4 Nov 2017, 22:18

      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.

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 4 Nov 2017, 23:11 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 4 Nov 2017, 23:17
      2
      • K kshegunov
        4 Nov 2017, 23:11

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

        use the pipe - |.

        N Offline
        N Offline
        nim108
        wrote on 4 Nov 2017, 23:17 last edited by nim108 11 Apr 2017, 23:19
        #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?

        K 1 Reply Last reply 4 Nov 2017, 23:22
        0
        • N nim108
          4 Nov 2017, 23:17

          @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?

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 4 Nov 2017, 23:22 last edited by kshegunov 11 Apr 2017, 23:23
          #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 4 Nov 2017, 23:39
          2
          • K kshegunov
            4 Nov 2017, 23:22
            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 4 Nov 2017, 23:39 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

            5/5

            4 Nov 2017, 23:39

            • Login

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