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. What to use instead of QMAKE_POST_LINK in TEMPLATE = subdirs projects?
Forum Updated to NodeBB v4.3 + New Features

What to use instead of QMAKE_POST_LINK in TEMPLATE = subdirs projects?

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

    Hi,
    I use QMAKE_POST_LINK to copy additional files into the target dir.
    For normal (sub)projects this works, as there is something build.

    However, in the .pro file of the subdirs template, using this mechanism does not work - i think it's because on this level nothing is build.

    So the question is what to use instead of QMAKE_POST_LINK on this level?

    my .pro file looks like:

    TEMPLATE = subdirs
    SUBDIRS += \
        store
    
    #this copies the lit test files to the build dir
    
    DISTFILES+= \
        $$PWD/lit.cfg
    
    # copy DISTFILES over to build Dir
    defineTest(copyToDestDir) {
        files = $$1
        dir = $$2
    
        for(file, files) {
            QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
        }
        export(QMAKE_POST_LINK)
    }
    
    copyToDestDir($$DISTFILES, $$OUT_PWD/)
    
    

    Thx
    Alex

    aha_1980A 1 Reply Last reply
    0
    • A alexqt143

      Hi,
      I use QMAKE_POST_LINK to copy additional files into the target dir.
      For normal (sub)projects this works, as there is something build.

      However, in the .pro file of the subdirs template, using this mechanism does not work - i think it's because on this level nothing is build.

      So the question is what to use instead of QMAKE_POST_LINK on this level?

      my .pro file looks like:

      TEMPLATE = subdirs
      SUBDIRS += \
          store
      
      #this copies the lit test files to the build dir
      
      DISTFILES+= \
          $$PWD/lit.cfg
      
      # copy DISTFILES over to build Dir
      defineTest(copyToDestDir) {
          files = $$1
          dir = $$2
      
          for(file, files) {
              QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
          }
          export(QMAKE_POST_LINK)
      }
      
      copyToDestDir($$DISTFILES, $$OUT_PWD/)
      
      

      Thx
      Alex

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @alexqt143 the SUBDIRS file is really just for specifying the sub-projects. Either move the copy logic into an existing project, or create one for that.

      Qt has to stay free or it will die.

      1 Reply Last reply
      3
      • A Offline
        A Offline
        alexqt143
        wrote on last edited by
        #3

        Ok, to bad.
        This would mean that I need to strip of one directory from the $$PWD and $$OUT_PWD.
        Could I just use %%PWD/../lit.cfg and $$OUT_PWD/../ or is there a qmake scefific (platform independent) way of doing so?

        Thx
        Alex

        aha_1980A 1 Reply Last reply
        0
        • A alexqt143

          Ok, to bad.
          This would mean that I need to strip of one directory from the $$PWD and $$OUT_PWD.
          Could I just use %%PWD/../lit.cfg and $$OUT_PWD/../ or is there a qmake scefific (platform independent) way of doing so?

          Thx
          Alex

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @alexqt143

          You could put a copyfiles.pro parallel to the subdirs .pro file and do something like this (untested!):

          TEMPLATE = subdirs
          SUBDIRS += \
            store \
            copyfiles
          
          copyfiles.file = copyfiles.pro
          copyfiles.depends = store
          

          The depends line makes sure, copy action takes place after your main project has been build.

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          3
          • A Offline
            A Offline
            alexqt143
            wrote on last edited by
            #5

            Hi,
            thanks for the hint.
            However, in this case, one needs to do some extra work to suppress warnings, as qmake wants to compile something.
            One could follow: link this approach.

            I decided to add the %%PWD/../lit.cfg and $$OUT_PWD/../ approach to one of the test instead.

            For those looking for a way to copy the files also if only one of the DISTFILES changed (and none of the main src files) see the approach below. Comes at cost to re-link the main code:

            # copy DISTFILES over to build Dir
            defineTest(copyToDestDir) {
                files = $$1
                dir = $$2
            
                for(file, files) {
                    myCopyCommands += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
                }
            
                export(myCopyCommands)
            }
            
            
            copyToDestDir($$DISTFILES, $$OUT_PWD/)
            
            #add a target which is executed if one of the distfiles changed
            copyTarget.target = copyTestFiles
            copyTarget.commands = $$myCopyCommands
            
            QMAKE_EXTRA_TARGETS += copyTarget
            PRE_TARGETDEPS+= copyTestFiles
            
            

            Alex

            1 Reply Last reply
            1

            • Login

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