[CMake] Adding a generated file as a dependency to a target

Andreas Pakulat apaku at gmx.de
Fri Jan 27 13:17:16 EST 2012


On 27.01.12 17:41:39, Schuchard, Matthew wrote:
> Contrary to the CMake FAQ, but consistent with what I have been reading elsewhere, it does not seem possible for me with CMake 2.8.6 to add a generated file as a dependency to a target, even in the same directory.
> 
> I have done something similar to the following:
> 
> add_custom_command(OUTPUT foo.ext)
> add_executable(foo foo2.ext)
> add_custom_target(foo_custom DEPENDS foo.ext)
> set_source_files_properties(foo.ext PROPERTIES GENERATED TRUE)
> add_dependencies(foo foo_custom)
> 
> The above will not cause a dependency of foo on foo.ext, and when attempting to run make, throws an error of:
> No rule to make target 'CMakeFiles/foo_custom.dir/requires'
> 
> Could anyone please shine some light on this?
> What I have been reading elsewhere (CMake mailing list, stackoverflow, etc.) is that the majority of the time, attempting something similar to the above does not succeed.
> Could this fix be included among 2.8.8 updates?

First someone needs to find out what goes wrong in your case. Here with
CMake 2.8.5 the attached example works fine.

Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmakedep.zip
Type: application/zip
Size: 705 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120127/c1350b07/attachment.zip>


More information about the CMake mailing list