Reputation: 421
My problem is to manage some text tables contained in a folder used in my Qt project; when I compile release or debug version, I must copy the same folder in all place where project is compiled. The disadvantage is when I change a data in one of text tables and forget to copy this table in all places. Is it possible to set an absolute path or an unique folder for all files in some ways external to Qt sources, headers and classes file?
Upvotes: 0
Views: 79
Reputation: 558
You can use QMAKE_POST_LINK to add a custom copy command after your build process is finished.
For example I use this code in my PRO file to copy the release executable into a dedicated bin folder that is used for building a setup executable.
win32 {
release {
COPY_CMD = "$$OUT_PWD\\release\\$${TARGET}.exe $$PWD\\bin\\$${TARGET}.exe"
COPY_CMD = $${QMAKE_COPY} $$replace( COPY_CMD, "/", "\\" ) $$escape_expand( \\n\\t )
QMAKE_POST_LINK += $$COPY_CMD
}
}
You can do the same, just in the other direction and copy your needed files into your build path.
For example, this would create a folder MyList in your build path and copy every *.txt from your source root to this folder.
win32 {
release {
COPY_CMD += mkdir $$OUT_PWD/MyList &
COPY_CMD += copy $$IN_PWD/MyList/*.txt $$OUT_PWD/MyList/*.txt &
COPY_CMD = $$replace( COPY_CMD, "/", "\\" ) $$escape_expand( \\n\\t )
QMAKE_POST_LINK += $$COPY_CMD
}
}
Upvotes: 1