CMake: how do i depend on output from a custom target?

醉酒当歌 提交于 2020-01-21 13:57:37

问题


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.

Thanks for any help. Cheers!


回答1:


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.



来源:https://stackoverflow.com/questions/4066811/cmake-how-do-i-depend-on-output-from-a-custom-target

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!