[CMake] [BUG] add_custom_command(TARGET ...) can't see in scope target

Dan Liew dan at su-root.co.uk
Tue Aug 4 22:46:01 EDT 2015


On 4 August 2015 at 14:32, Iosif Neitzke <iosif.neitzke+cmake at gmail.com> wrote:
> And:
>
> "A target created in the same directory (CMakeLists.txt file) that
> specifies any output of the custom command as a source file is given a
> rule to generate the file using the command at build time."
>
> http://www.cmake.org/cmake/help/v3.3/command/add_custom_command.html

That documentation is for the first signature of
``add_custom_command()`` (Generating Files section in the docs) which
I'm not using here. I'm using the other signature (Build Events in the
docs) which mentions nothing about add_custom_command(TARGET ...)
working only on targets created in the same directory.

CMakes behaviour could be clearer here, it should probably raise an
error rather than pretending that the target doesn't exist which is
clearly does.

> But it's not super clear in the documentation.

Agreed!


More information about the CMake mailing list