What to use instead of QMAKE_POST_LINK in TEMPLATE = subdirs projects?
-
Hi,
I use QMAKE_POST_LINK to copy additional files into the target dir.
For normal (sub)projects this works, as there is something build.However, in the .pro file of the subdirs template, using this mechanism does not work - i think it's because on this level nothing is build.
So the question is what to use instead of QMAKE_POST_LINK on this level?
my .pro file looks like:
TEMPLATE = subdirs SUBDIRS += \ store #this copies the lit test files to the build dir DISTFILES+= \ $$PWD/lit.cfg # copy DISTFILES over to build Dir defineTest(copyToDestDir) { files = $$1 dir = $$2 for(file, files) { QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t) } export(QMAKE_POST_LINK) } copyToDestDir($$DISTFILES, $$OUT_PWD/)Thx
Alex -
Hi,
I use QMAKE_POST_LINK to copy additional files into the target dir.
For normal (sub)projects this works, as there is something build.However, in the .pro file of the subdirs template, using this mechanism does not work - i think it's because on this level nothing is build.
So the question is what to use instead of QMAKE_POST_LINK on this level?
my .pro file looks like:
TEMPLATE = subdirs SUBDIRS += \ store #this copies the lit test files to the build dir DISTFILES+= \ $$PWD/lit.cfg # copy DISTFILES over to build Dir defineTest(copyToDestDir) { files = $$1 dir = $$2 for(file, files) { QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t) } export(QMAKE_POST_LINK) } copyToDestDir($$DISTFILES, $$OUT_PWD/)Thx
Alex@alexqt143 the SUBDIRS file is really just for specifying the sub-projects. Either move the copy logic into an existing project, or create one for that.
-
Ok, to bad.
This would mean that I need to strip of one directory from the $$PWD and $$OUT_PWD.
Could I just use %%PWD/../lit.cfg and $$OUT_PWD/../ or is there a qmake scefific (platform independent) way of doing so?Thx
AlexYou could put a
copyfiles.proparallel to the subdirs .pro file and do something like this (untested!):TEMPLATE = subdirs SUBDIRS += \ store \ copyfiles copyfiles.file = copyfiles.pro copyfiles.depends = storeThe
dependsline makes sure, copy action takes place after your main project has been build.Regards
-
Hi,
thanks for the hint.
However, in this case, one needs to do some extra work to suppress warnings, as qmake wants to compile something.
One could follow: link this approach.I decided to add the %%PWD/../lit.cfg and $$OUT_PWD/../ approach to one of the test instead.
For those looking for a way to copy the files also if only one of the DISTFILES changed (and none of the main src files) see the approach below. Comes at cost to re-link the main code:
# copy DISTFILES over to build Dir defineTest(copyToDestDir) { files = $$1 dir = $$2 for(file, files) { myCopyCommands += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t) } export(myCopyCommands) } copyToDestDir($$DISTFILES, $$OUT_PWD/) #add a target which is executed if one of the distfiles changed copyTarget.target = copyTestFiles copyTarget.commands = $$myCopyCommands QMAKE_EXTRA_TARGETS += copyTarget PRE_TARGETDEPS+= copyTestFilesAlex