如何在qmake生成的Makefile中添加自定义目标? [英] How to add custom targets in a qmake generated Makefile?
问题描述
我使用qmake生成Makefile,并且效果很好.但是,有时我想在生成的Makefile中添加更多内容,而不必编辑生成的Makefile.
I use qmake to generate the Makefile, and that works well. However, sometimes I want to add more stuff to the generated Makefile without having to edit the generated Makefile.
假设我们在源代码旁边有一个Doxygen目录,我需要在其中运行一些doxygen命令来生成文档.因此,最好在主Makefile中将此作为目标.但是作为默认qmake,它不了解这种类型的额外内容.
Let's say that we beside the source code have a Doxygen directory, and there I need to run some doxygen commands to generate the documentation. So it would be nice to have this as a target in the main Makefile. But as default qmake do not understand this type of extra stuff.
所以我可以添加一些内容告诉qmake在"doxygen"目录中包含辅助Makefile,或者直接在qmake配置中添加额外目标"吗?
So can I add something to tell qmake to include a secondary Makefile in the "doxygen" dir, or maybe add "extra targets" directly in the qmake config?
也许是这样的:
推荐答案
这是一个老问题,但是我还是会添加一个答案.
This is an old question, but I'll add an answer anyway.
虽然qmake中似乎似乎不普遍支持自定义规则,但假设使用GNU make,有一种简单的方法可以做到这一点.只需创建一个名为makefile的文件(全部小写):
While there seems to be no general support for custom rules in qmake, there is a simple way to do it, assuming GNU make. Just create a file called makefile (all lower case):
include Makefile
re: clean
$(MAKE) all
最后两行是我的自定义规则.
where the last two lines are my custom rule.
如果两者都存在,GNU make将使用makefile而不是Makefile.
GNU make will use makefile, not Makefile, if both exist.
顺便说一句,re规则解决了"make -j8 clean all"的问题.该命令将在完成清理之前开始执行所有操作. re规则可确保顺序性.
BTW, the re rule solves the problem with "make -j8 clean all". This command will start doing all before it has finished doing clean. The re rules guarantees sequentiality.
这篇关于如何在qmake生成的Makefile中添加自定义目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!