cmake: struggling with add_custom_command dependencies

后端 未结 4 1014
面向向阳花
面向向阳花 2021-02-12 23:06

I\'m trying to get a file produced by an add_custom_command in one directory to be a dependency of an add_custom_command in another directory.

In the first directory (li

4条回答
  •  孤城傲影
    2021-02-12 23:34

    This is a non-answer but a clarification to one of your answers above.

    According to the cmake documents, a custom target created by add_custom_target is always considered out of date and is always built.

    IMO, the cmake documents should say instead:

    A custom target created by add_custom_target is always considered out of date and is always built, but only when requested.

    That means that if all of your targets are marked as EXCLUDE_FROM_ALL, and you have add_custom_target commands that create new targets, and you type make from the command line with no targets specified, the targets added with add_custom_target are not built. But if you spell them out on the make command line explicitly, then they are built. Also, there is the ALL keyword that you can specify to the add_custom_target to force those to be built as a part of the all rule, which I believe means when make is executed without arguments.

提交回复
热议问题