After several years of working with CMake, I have to say that I still do not understand the behavior of the DEPENDS clause in add_custom_command.<div><br></div><div>The main problem is a fairly simple one: I have an add_custom_command in one subdirectory, the output of which is needed by an add_custom_command in another subdirectory. Since add_custom_command can't refer to targets in other directories, I have followed the advice of various experts (on this list and on stackoverflow) and made additional targets via add_custom_target, in both subdirectories.</div>
<div><br></div><div>So in directory A, I have an add_custom_command which generates a file, and then I have an add_custom_target which depends on that file. In directory B, I have another custom target which uses add_dependencies to add a dependency to the custom target defined in A. Finally, I have an add_custom_command which has a DEPENDS clause adding a dependency to the target defined in that directory.</div>
<div><br></div><div>It's the last step that doesn't work - it says "No rule to make target <targetname>, needed by <filename>. Stop." Even though <targetname> is defined earlier in the same CMakeLists.txt file.</div>
<div><br></div><div>According to my reading of the CMake documentation, this should work (although the docs are quite confusing on this point). Here's what the doc says about the DEPENDS clause of add_custom_command: "If DEPENDS specifies any target (created by an ADD_* command) a target-level dependency is created to make sure the target is built before any target using this custom command." I'm assuming that the words "specifies any target" means that you can pass the name of a target as an argument to DEPENDS. If that's not what it means, please tell me.</div>
<div><br><div><div>Caveat: I'm still working with 2.8.3 - I see that generator expressions in 2.8.4 would solve my problems, but at the moment I'm stuck with the version that Ubuntu distributes.<br clear="all"><div>
<br></div><div>In any case, I've been struggling with this specific problem off and on for over 3 years, asking for help on various forums, and I've never found an answer that actually works for me.</div><div><br>
</div>-- <br>-- Talin<br>
</div></div></div>