سؤال

I am sorry if the question was already asked but after some research I couldn't find an answer. I want to copy the .exe of a project into a folder automatically.

I am using Qt creator 5.0.1 MSCV2010 and it always makes two outputs: release and debug.

For example, I want the /release/project.exe to be in /release/exec/project.exe.

I saw I can copy file like .dll with in a .pro with:

INSTALLS =

But it only work with files which already exist, or the .exe is generated after the compilation. I think I can specify this into:

projects settings->Build compilation->step Make : jom.exe in C:\path\to\project-release

But I don't know what argument is needed, Regards

هل كانت مفيدة؟

المحلول

On Windows you can use DLLDESTDIR variable which specifies where to copy the target dll or exe. Just add this to your .pro :

CONFIG(release, debug|release): DLLDESTDIR +=  $$PWD/../exec

On Linux you can use QMAKE_POST_LINK variable which contains the command to execute after linking the TARGET together. So it is like:

CONFIG(release, debug|release): QMAKE_POST_LINK += $$quote(cp project $$PWD/../exec)

Here project is the name of the target file which you provide by TARGET = project

These will copy the executable binary to a directory named exec one level upper than the program working directory. You can have your arbitrary path.

نصائح أخرى

add a custom build step with the command an parameters

for windows (assuming you are doing this for the release build):

xcopy
Release\<target.exe> path\to\destination\file.exe /Y
%{buildDir}

This should work. I couldn't find any variable that points the target_path. So I defined it:

### to copy target file to build folder
CONFIG(debug, debug|release) {
    TARGET_PATH = $$OUT_PWD/debug
}
CONFIG(release, debug|release) {
    TARGET_PATH = $$OUT_PWD/release
}

win32: QMAKE_POST_LINK += copy /y "$$shell_path($$TARGET_PATH/app_name.exe)" "$$shell_path($$PWD/../build/)"
unix: QMAKE_POST_LINK += cp "$$shell_path($$TARGET_PATH/app_name)" "$$shell_path($$PWD/../build/)"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top