[英]How can i add a custom build step in Qt Creator project wizard?
I used to have a project templates, when i code in Visual Studio, but now i have to use Qt Creator and find out it has something very similar, which called "Project Wizard". 当我在Visual Studio中编写代码时,我曾经有一个项目模板,但是现在我必须使用Qt Creator并发现它具有非常相似的功能,称为“项目向导”。 I need to have text file, which will be copied to build folder, and solved it by adding a new build step, but i can't understand how to add a new build step in project wizard file.
我需要有文本文件,该文件将被复制到构建文件夹,并通过添加一个新的构建步骤来解决它,但是我不明白如何在项目向导文件中添加一个新的构建步骤。 So, i took a "plaincpp" project wizard to base on, and it hasn't got any cmake files to change.
因此,我以一个“ plaincpp”项目向导为基础,它没有任何cmake文件可更改。 Also i found, what Qt Creator stores build steps in *.pro.user file.
我还发现,Qt Creator在* .pro.user文件中存储的构建步骤。
您可以将QMAKE_POST_LINK += /path/to/some/script/or/binary
到your_project.pro
文件,并编写一个简单的bash脚本或任何您想执行的脚本来复制文件。
As stated by @0x35 you can use the QMAKE_POST_LINK += <arguments>
by putting it anywhere in the .pro file. 如@ 0x35所述,您可以通过将
QMAKE_POST_LINK += <arguments>
放在.pro文件中的任何位置来使用它。 (On windows this method sometimes requires a clean first). (在Windows上,此方法有时需要先清理)。
Other arguments to consider as implied by the comments of @hoholok (and some research): @hoholok的评论(和一些研究)所隐含的其他论点包括:
$$OUT_PWD
and $$OUT_PWD
找到当前的构建目录,然后 $$PWD
$$PWD
的源目录 $$_PRO_FILE_PWD_
$$_PRO_FILE_PWD_
../
ex: $${OUT_PWD}/../otherFolder/
$${OUT_PWD}/../otherFolder/
使用../
ex: $${OUT_PWD}/../otherFolder/
For the Windows user the directories given above use forward slashes. 对于Windows用户,上面给出的目录使用正斜杠。 This in turn causes the builds to fail.
这继而导致构建失败。 The forward slashes should be turned into two backslashes.
正斜杠应变成两个反斜杠。 ex (works in solution .pro file):
ex(在解决方案.pro文件中有效):
Directory_to_Use = some_Directory #initialization for linux directory
PWD_WIN = $${OUT_PWD} #Set PWD_WIN to output directory
win32 # this code only executes on a windows machine
{
Directory_to_Use = C:\\_Dev\\Qt\5.9.1\\mingw53_32\\bin #change linux path to the windows path
PWD_WIN ~= s,/,\\,g #change all forward slashes into double backslashes
}
QMAKE_POST_LINK += COPY $$Directory_to_Use\\Qt5* $$PWD_WIN\\debug #command that works on both linux and windows
This code example snippet copies all the Qt dlls from my Qt installed directory into the project build directory. 此代码示例摘录将所有Qt dll从我的Qt安装目录复制到项目构建目录中。
If more than one command needs to be executed post build just add another QMAKE_POST_LINK += <arguments>
or even put it in a for loop as here: for loop in .pro file . 如果构建后需要执行多个命令,只需添加另一个
QMAKE_POST_LINK += <arguments>
,甚至将其放入for循环中即可,如下所示: .pro文件中的for循环 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.