MantisBT - CMake
View Issue Details
0014633CMakeCMakepublic2013-12-05 21:242016-06-10 14:31
Sean Patrick Santos 
Kitware Robot 
normalfeatureN/A
closedmoved 
 
 
0014633: There should be a standard way to communicate that a source is generated to parent/sibling directories.
I'm referring to something that's described on the wiki here:

http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_add_a_dependency_to_a_source_file_which_is_generated_in_a_subdirectory.3F [^]

The method described there is a bit weak when source files from the same directory need to be added to targets in multiple directories. In that case, each target has to "know" which source files are generated code, even though it should be possible, in principle, for CMake to figure this out on its own. If a source file is replaced with a generated version (or vice versa), every directory that uses that file has to be updated with this info.

There are two possible changes that would really help here.

To me, the ideal solution would be for add_custom_command calls to be visible when adding a target in a different directory. That is, it would be nice if using a generated source in another directory "just worked" with no source file properties or custom targets required.

Alternatively, source file properties could have scope beyond the current directory (which seems to be a more intuitive behavior anyway). That way, instead of a directory having to "know" that a file in a different directory was generated, it could just loop over files, and then perform an add_dependencies call on each file that had the GENERATED property set. (I will probably implement something similar to this strategy in my own project, by using variables rather than a property, but it will be rather non-standard and less straightforward than if I could check the GENERATED property.)

(P.S.: In my case, the targets are test executables that each need a different subset of the source files, so I cannot use an intermediate library, even an object library, to simplify things. Each source file really does have to be mentioned in one way or another in each of the directories that builds an executable against it.)
No tags attached.
Issue History
2013-12-05 21:24Sean Patrick SantosNew Issue
2016-06-10 14:29Kitware RobotNote Added: 0042443
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042443)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.