[CMake] problem with add_custom_command / add_custom_target in different directories

James Bigler jamesbigler at gmail.com
Mon Mar 30 01:59:28 EDT 2009


On Wed, Feb 25, 2009 at 7:54 AM, Brad King <brad.king at kitware.com> wrote:
> Michael Wild wrote:
>>
>> On 25. Feb, 2009, at 7:25, Philip Lowman wrote:
>>>
>>> When I invoke add_custom_target() in the
>>> parent directory it causes an error in the makefiles.
>>
>> To me this appears to be a bug in the Makefile generator. I also tried to
>> make a "untarFoo" custom target in test/CMakeLists.txt, which depended on
>> the output of the custom command and then have the "untar" target depend on
>> "untarFoo", but that didn't work out either.
>
> Custom commands are registered only in the directory where they appear.
> When Philip points the DEPENDS of add_custom_target at a file, CMake looks
> only at custom commands added in that directory for a rule.  Since it
> doesn't find one it assumes that the user is referring to a file that will
> be on disk by the time the custom target builds.  This isn't the case, so
> make complains it can't find the file.

I'm kind of resurrecting this old thread, because I just ran into this
issue and found no documentation on it in the CMake docs.  I filed a
documentation bug:
http://public.kitware.com/Bug/view.php?id=8815

BTW, is there a particular reason why custom commands are only
registered in the directory where they appear?  They seem kind of like
the little brother of a target, and targets are global.

James


More information about the CMake mailing list