如何在cmake目标中添加依赖关系 [英] How to add dependency in cmake targets

查看:1587
本文介绍了如何在cmake目标中添加依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cmake中定义了一个自定义目标。我现在想确保这个目标只有在cmake目标 test 被执行时才生成。如何实现这一点。

I have defined a custom target in cmake. I now want to ensure that this target is only build when the cmake target test was executed. How can I achieve this.

假设我有一个目标 make coverage code> make test 之前调用,或者在执行之前调用 make test

Lets say that I have a target make coverage which should depend on the target make test to be called before, or call make test before executing.

我如何在cmake中定义这个行为?

How can I define this behavior in cmake?

这里我的代码没有按预期工作。

Here my code that did not work as expected. I want to achive that make coverage depend that make test has to be called before.

    ADD_CUSTOM_TARGET(
        coverage COMMAND /bin/bash ${LIBPIPE_BINARY_DIR}/cmake/scripts/coverage.sh
        DEPENDS test
    )  


推荐答案

CMake常见问题说明定义自定义目标的 add_custom_command / add_custom_target 命令具有DEPENDS参数。

The CMake FAQ states that the add_custom_command/add_custom_target commands, which define custom targets, have a DEPENDS parameter.

这篇关于如何在cmake目标中添加依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆