CMake:我如何依赖自定义目标的输出?

发布于 2024-09-29 21:16:06 字数 420 浏览 0 评论 0原文

我无法修改的传统 Make 流程会生成一个我必须对其进行一些后处理的目标。

我使用 add_custom_target 强制 Makefile 始终运行。 我使用 add_custom_command 进行后处理步骤。

问题在于,就 CMake 而言,add_custom_target 无法生成输出。那么,如何为后处理步骤设置依赖关系?我不想运行这些步骤,除非外部 Make 实际上更新了其目标。

add_custom_command 不能使用 add_custom_target 的名称作为 DEPENDS。我尝试了这个,它假设 add_custom_target 名称只是一个文件,无法找到它。

A traditional Make process that I cannot modify produces a target on which I must do some post-processing.

I use add_custom_target to force the Makefile to always run.
I use add_custom_command for my post-processing steps.

The problem is that add_custom_target cannot produce an output as far as CMake is concerned. So, how do I setup a dependency for the post-processing steps? I don't want to run these steps unless the external Make actually updated its target.

The add_custom_command cannot use the name of the add_custom_target as a DEPENDS. I tried this and it assumes that the add_custom_target name is just a file and cannot find it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪花飘飘的天空 2024-10-06 21:16:06

使 add_custom_command 调用依赖于一个文件,该文件在“外部 make 实际更新其目标”时发生更改。仅当自定义命令的 DEPENDS 之一比其 OUTPUT 新时,该自定义命令才会运行。

当 CMake add_custom_command 调用是完整路径文件名引用时,DEPENDS 调用最适合旧版本的 CMake。较新版本的 CMake 应使用文件名或 CMake 目标名称引用。

Make the add_custom_command call depend on a file that changes when "the external make actually updated its target." The custom command will only run if one of its DEPENDS is newer than its OUTPUT.

The DEPENDS for CMake add_custom_command calls work best with older versions of CMake when they are full path file name references. More recent versions of CMake should work with file name or CMake target name references.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文