Qt qmake - 如何阻止它添加删除目标的规则
我正在尝试将单元测试添加到一组其他测试中。所有测试都位于自己的子目录中,每个子目录都有自己的 .pro 文件和包含测试本身的 .cpp 文件。在子目录之一中运行 qmake 会创建一个 Makefile,然后运行 make 运行编译器来生成 TARGET。测试实际上是由“check”目标运行的 - 即使用“make check”。
我试图添加的测试是不同的,但它试图假装行为相同。
它的不同之处在于它是一个 perl 脚本,因此不需要编译。然而,它确实需要运行 - 所以“make check”需要起作用。
我有一个 .pro 文件大部分工作 - 'qmake'、'make'、'make check' 和 'make clean' 可以工作,但是 'make distclean' 删除了我的脚本(因为它假设它可以通过以下方式重新生成)编译一些东西)。
那么,问题是,如何阻止它删除我的脚本?
也许我应该采取其他方法。我尝试过“子目录”模板,但这不仅仅是删除 Makefile 中删除目标的行。
有想法吗?
使用带有 Qt 4.6.0 的 Ubuntu Linux。
I am trying to add a unit test to a group of other tests. All the tests are in their own subdirectories, each with it's own .pro file and the .cpp file which contains the tests themselves. Running qmake in one of the subdirectories creates a Makefile, and then running make runs the compiler to make the TARGET. The tests are actually run by the 'check' target - ie with 'make check'.
The test I'm trying to add is different, but it is trying to pretend to behave the same way.
It is different because it is a perl script and so doesn't need to be compiled. It does, however, need to be run - so 'make check' needs to work.
I had a .pro file working for the most part - 'qmake', 'make', 'make check', and 'make clean' would work, but 'make distclean' removed my script (since it assumes it can be regenerated by compiling something).
So, the question is, how do I stop it from removing my script?
Perhaps there's some other approach I should be taking. I had tried the 'subdirs' TEMPLATE, but that does more than just remove the line in Makefile that deletes the TARGET.
Ideas?
Using Ubuntu Linux with Qt 4.6.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会研究 自定义目标 您的脚本的功能。也许是这样的:
以这种方式执行操作将在依赖项更改时运行 check 命令,但只要您不指定
check.target
那么它就不应该删除任何内容。 (如果您的脚本确实产生输出,那么也许应该在check.target
中。)此外,由于它被指定为“额外”命令,qmake 不应该创建命令来删除您的脚本一个distclean。这是假设您的脚本位于其自己的子目录中(您声明的),并且是需要在该子目录中运行的唯一“检查”命令(问题暗示,但没有直接声明)。
I would look into the custom target capabilities for your script. Maybe something like this:
Doing things this way will run the check command when the dependencies change, but as long as you don't specify
check.target
then it shouldn't remove anything. (If your script does produce output, then perhaps that should be incheck.target
.) Also, since it is specified as an "extra" command, qmake shouldn't create commands to delete your script in a distclean.This is assuming that your script is in its own subdirectory (which you state), and is the only "check" command that needs run in that subdirectory (kind of implied by the question, but not directly stated).