Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Copy file at build time in Qt creator.
Forum Updated to NodeBB v4.3 + New Features

Copy file at build time in Qt creator.

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
13 Posts 5 Posters 5.2k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Technically, that copy file custom step is what you can do in your .pro file as a post build step.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    2
    • F Offline
      F Offline
      federico.massimi
      wrote on last edited by
      #3

      @SGaist OK, but it don't work. What's the correct way to create a copy file custom build step?

      aha_1980A 1 Reply Last reply
      0
      • F federico.massimi

        @SGaist OK, but it don't work. What's the correct way to create a copy file custom build step?

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

        @federico.massimi Neither $COPY_FILE nor $$PWD are valid Qt Creator variables. The A -> B button opens a dialog where you can choose variables.

        Cf. https://stackoverflow.com/questions/35970727/use-of-variables-like-builddir-in-qtcreator-kit-settings-in-qt5

        Qt has to stay free or it will die.

        1 Reply Last reply
        1
        • F Offline
          F Offline
          federico.massimi
          wrote on last edited by
          #5

          @aha_1980 said in Copy file at build time in Qt creator.:

          OK, I found correct variable for source path (%{sourceDir}) and build directory (%{buildDir}), but I found nothing about the copy command.

          I've seen this post:
          https://stackoverflow.com/questions/20324061/where-are-variables-such-as-mkdir-and-copy-dir-defined
          but it seems deprecated now.
          Currently, what is the copy command MACRO to be inserted in the custom build step?

          aha_1980A 1 Reply Last reply
          0
          • F federico.massimi

            @aha_1980 said in Copy file at build time in Qt creator.:

            OK, I found correct variable for source path (%{sourceDir}) and build directory (%{buildDir}), but I found nothing about the copy command.

            I've seen this post:
            https://stackoverflow.com/questions/20324061/where-are-variables-such-as-mkdir-and-copy-dir-defined
            but it seems deprecated now.
            Currently, what is the copy command MACRO to be inserted in the custom build step?

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

            @federico.massimi said in Copy file at build time in Qt creator.:

            Currently, what is the copy command MACRO to be inserted in the custom build step?

            There is no such macro.

            Qt has to stay free or it will die.

            F 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @federico.massimi said in Copy file at build time in Qt creator.:

              Currently, what is the copy command MACRO to be inserted in the custom build step?

              There is no such macro.

              F Offline
              F Offline
              federico.massimi
              wrote on last edited by
              #7

              @aha_1980
              OK, but if it doesn't exist how can I create a build step to copy a file to the destination folder?

              aha_1980A 1 Reply Last reply
              0
              • F federico.massimi

                @aha_1980
                OK, but if it doesn't exist how can I create a build step to copy a file to the destination folder?

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

                @federico.massimi you can call whatever command you like to call, for example copy. I'm no sure if I understand your question.

                Qt has to stay free or it will die.

                F 1 Reply Last reply
                0
                • aha_1980A aha_1980

                  @federico.massimi you can call whatever command you like to call, for example copy. I'm no sure if I understand your question.

                  F Offline
                  F Offline
                  federico.massimi
                  wrote on last edited by
                  #9

                  @aha_1980
                  Yes, ok, I realized that I can use any command, I'm asking if a macro existed in order to be multiplatform.
                  Otherwise I have to create a QT creator project in which I put the copy command for Linux, a QT creator project in which I put the copy command for Windows etc etc.

                  But from what I understand there is no macro to create a multiplatform copy command. Right?

                  aha_1980A 1 Reply Last reply
                  0
                  • F federico.massimi

                    @aha_1980
                    Yes, ok, I realized that I can use any command, I'm asking if a macro existed in order to be multiplatform.
                    Otherwise I have to create a QT creator project in which I put the copy command for Linux, a QT creator project in which I put the copy command for Windows etc etc.

                    But from what I understand there is no macro to create a multiplatform copy command. Right?

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

                    @federico.massimi said in Copy file at build time in Qt creator.:

                    But from what I understand there is no macro to create a multiplatform copy command. Right?

                    Correct.

                    But that would not help, anyway. Everything you put in these custom build step fields is local to your machine. If you want these actions to happen on each machine your project is running, you have to put appropriate commands into your .pro file.

                    Qt has to stay free or it will die.

                    F 1 Reply Last reply
                    2
                    • aha_1980A aha_1980

                      @federico.massimi said in Copy file at build time in Qt creator.:

                      But from what I understand there is no macro to create a multiplatform copy command. Right?

                      Correct.

                      But that would not help, anyway. Everything you put in these custom build step fields is local to your machine. If you want these actions to happen on each machine your project is running, you have to put appropriate commands into your .pro file.

                      F Offline
                      F Offline
                      federico.massimi
                      wrote on last edited by
                      #11

                      @aha_1980
                      OK, solved in this way:

                      unix{
                          QMAKE_POST_LINK += $$quote(cp $$PWD/sett.ini $$OUT_PWD$$escape_expand(\n\t))
                      }
                       win32 {
                        QMAKE_POST_LINK += $$quote(cmd /c copy /y $$PWD\sett.ini $$OUT_PWD$$escape_expand(\n\t))
                      }
                      
                      1 Reply Last reply
                      2
                      • Y Offline
                        Y Offline
                        YTKOHOC
                        wrote on last edited by YTKOHOC
                        #12

                        Hi, for me the best ever solution for copy files on build is using file_copies.prf.
                        You may find example of usage in that answer on SOF:

                        Qt 5.6 added this as an undocumented feature:

                        CONFIG += file_copies

                        Invent a name to describe the files you want to copy:

                        COPIES += myDocumentation

                        List the files that you want to copy, in its .files member:

                        myDocumentation.files = $$files(text/docs/*.txt)

                        Specify the destination path in the .path member:

                        myDocumentation.path = $$OUT_PWD/documentation

                        Optionally specify a base path to be trimmed from the source paths:

                        myDocumentation.base = $$PWD/text/docs

                        It basically works by doing the same things as many of the other answers here. See file_copies.prf for the gory details.

                        The interface is very similar to that for INSTALLS.

                        I tested it on Windows and Linux. And with nested directories too.

                        1 Reply Last reply
                        0
                        • W Offline
                          W Offline
                          William J. Lara
                          Banned
                          wrote on last edited by
                          #13
                          This post is deleted!
                          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