QMake – how to copy a file to the output

QMake – how to copy a file to the output

Asked on December 24, 2018 in Qt.
Add Comment


  • 3 Answer(s)

    How to copy files to the DESTDIR for Windows and Linux:

    linux-g++{
      #...
      EXTRA_BINFILES += \
          $${THIRDPARTY_PATH}/gstreamer-0.10/linux/plugins/libgstrtp.so \
          $${THIRDPARTY_PATH}/gstreamer-0.10/linux/plugins/libgstvideo4linux2.so
      for(FILE,EXTRA_BINFILES){
          QMAKE_POST_LINK += $$quote(cp $${FILE} $${DESTDIR}$$escape_expand(\n\t))
        }
    }
     
    win32 {
       #...
       EXTRA_BINFILES += \
          $${THIRDPARTY_PATH}/glib-2.0/win32/bin/libglib-2.0.dll \
          $${THIRDPARTY_PATH}/glib-2.0/win32/bin/libgmodule-2.0.dll
       EXTRA_BINFILES_WIN = $${EXTRA_BINFILES}
       EXTRA_BINFILES_WIN ~= s,/,\\,g
         DESTDIR_WIN = $${DESTDIR}
     DESTDIR_WIN ~= s,/,\\,g
     for(FILE,EXTRA_BINFILES_WIN){
                QMAKE_POST_LINK +=$$quote(cmd /c copy /y $${FILE} $${DESTDIR_WIN}$$escape_expand(\n\t))
       }
    }
    

     

    Answered on December 24, 2018.
    Add Comment

    In qmake function for reusability:

    # Copies the given files to the destination directory
    defineTest(copyToDestdir) {
        files = $$1
     
    for(FILE, files) {
        DDIR = $$DESTDIR
       
        # Replace slashes in paths with backslashes for Windows
        win32:FILE ~= s,/,\\,g
        win32:DDIR ~= s,/,\\,g
     
        QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
     }
      export(QMAKE_POST_LINK)
    }
    

     

    Answered on December 24, 2018.
    Add Comment

    Just try this link for more information  INSTALLS variable of qmake:

    images.path = $${DESTDIR}/images
    images.files += images/splashscreen.png
    images.files += images/logo.png
    INSTALLS += images
    

    Run the  make install.

    Answered on December 24, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.