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. How to copy a folder from source to build directory in qmake
Forum Updated to NodeBB v4.3 + New Features

How to copy a folder from source to build directory in qmake

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.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.
  • C Offline
    C Offline
    cebuger
    wrote on 18 Mar 2021, 15:16 last edited by
    #1

    Ive been using CMake in using QT and this is my first time using qmake.
    and I want to know how to copy an entire folder from my PWD (current source file where .pro is located) to the build directory.
    like I have a folder named "resources" where it contains multiple files, and i want to copy the folder to build directory like
    source
    main.cpp
    mainwindow.cpp
    [resources]
    .... res.out1

    target (build folder)
    [resources]
    Makefile
    Makefile.Debug
    ui_mainwindow.h

    All i see when googling are copy files, but when i modify it a little to copy to a folder (non existing or new one) none works,

    Any help?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Mar 2021, 19:54 last edited by
      #2

      Hi,

      Not a direct answer but since you are used to cmake and Qt 6 has switch its build system to cmake, why move to qmake ?

      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
      0
      • J Offline
        J Offline
        J.Hilk
        Moderators
        wrote on 19 Mar 2021, 06:12 last edited by
        #3

        I have posted this before, but I'm personnally using this:

        defineTest(copyToDestDir) {
            files = $$1
            dir = $$2
            # replace slashes in destination path for Windows
            win32:dir ~= s,/,\\,g
        
            for(file, files) {
                # replace slashes in source path for Windows
                win32:file ~= s,/,\\,g
        
                QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
            }
        
            export(QMAKE_POST_LINK)
        }
        

        It will copy the folder content from a to b
        copyToDestDir($$PWD/a, $$Deployment_Path/release/b)


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        3

        3/3

        19 Mar 2021, 06:12

        • Login

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