Copy files to output directory keeping the original path
-
I want to copy some file to the output directory after build and I wrote this in my project file:
OTHER_FILES += \ languages\translation_it.qm \ languages\translation_en.qm win32 { DESTDIR_WIN = $${OUT_PWD} DESTDIR_WIN ~= s,/,\\,g PWD_WIN = $${PWD} PWD_WIN ~= s,/,\\,g for(FILE, OTHER_FILES){ QMAKE_POST_LINK += $$quote(cmd /c copy /y $${PWD_WIN}\\$${FILE} $${DESTDIR_WIN}$$escape_expand(\\n\\t)) } }
It works, but:
- it copies the files only when a rebuild is issued. I'd like it copies them after each build
- it doesn't keep the original path. I.e. it copies the files (translation_en.qm) to the destination directory, without the path (languages/)
- the
OUT_DIR
is where the intermediate files are places, what is the real output directory, where the executables are? I.e.OUT_DIR/debug
-
@Mark81 said in Copy files to output directory keeping the original path:
- it copies the files only when a rebuild is issued. I'd like it copies them after each build
If there is a successful link involved it should work.
@Mark81 said in Copy files to output directory keeping the original path:
- it doesn't keep the original path. I.e. it copies the files (translation_en.qm) to the destination directory, without the path (languages/)
That is an issue of copy command restrictions. You may want to check xcopy which is more powerful. However, IIRC it also does not provide the functionality required.
@Mark81 said in Copy files to output directory keeping the original path:
- the
OUT_DIR
is where the intermediate files are places, what is the real output directory, where the executables are? I.e.OUT_DIR/debug
Why not using DESTDIR?
-
To add to what @koahnig said,
here's an excerpt from my current .pro file. Copies files(including specific sub dirs) just fine.TEMPLATE = app DESTDIR = deployment # copies the given files to the destination directory 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) } copyToDestDir($$PWD/translations, deployment/translations) copyToDestDir($$PWD/data/data, deployment/data) copyToDestDir($$PWD/data/Logo, deployment/Logo)
-
@koahnig said in Copy files to output directory keeping the original path:
If there is a successful link involved it should work.
You're right, I changed nothing hence it did nothing!
Why not using DESTDIR?
Because I have to set it manually. But I can live with that... I just set it and it works - of course.
-
@J.Hilk said in Copy files to output directory keeping the original path:
To add to what @koahnig said,
here's an excerpt from my current .pro file. Copies files(including specific sub dirs) just fine.Thank you very much. It works for me too! Just a question: it doesn't support wildcards, does it? I.e., something like:
copyToDestDir($$PWD/translations/*.qm, deployment/translations)
-
Hi,
IIRC, you can use
QMAKE_COPY_DIR)
for copying the content of a folder.