Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMake - how to copy a file to the output

How can I copy a file from my project to the output directory with qmake?

I'm compiling on Linux but in the future I'll compile it on Mac and Windows.

like image 495
Raphael Avatar asked Oct 21 '10 03:10

Raphael


People also ask

What is qmake command?

qmake will run in win32 mode. In this mode, Windows file naming and path conventions will be used, additionally testing for win32 (as a scope) will succeed. This is the default mode on Windows. -d. qmake will output (hopefully) useful debugging information.

What is .PRI file in Qt?

This is usually called Project Include File.

Where is .pro file in Qt?

Qt qmake Default "pro" file. If you start Qt Creator and select File -> New File or Project -> Application -> Qt Widgets application, Qt Creator will generate a project skeleton for you along with a "pro" file.


1 Answers

You can use a 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) } 

then use it as follows:

copyToDestdir($$OTHER_FILES) # a variable containing multiple paths copyToDestdir(run.sh) # a single filename copyToDestdir(run.sh README) # multiple files 
like image 176
Jake Petroules Avatar answered Sep 28 '22 12:09

Jake Petroules