I&#39;d be interested to know the answer to this also. However, failing a way to do it directly, one thought that would at least make this feasible would be to implement your own versions of eg. add_executable() and add_library() which keep track of the extra information and then call the original versions. You&#39;d have to name them something different and then change all of your CMakeLists to use your form, but it&#39;s at least doable. (You can actually override the existing definitions of add_executable() and add_library() with your own functions, but unfortunately I never found a way from within my overwritten forms to call the original, so it&#39;s not very useful.)<br>
<br>Ceej<br>aka Chris Hillery<br><br><div class="gmail_quote">On Sun, Sep 5, 2010 at 3:51 PM, Clifford Yapp <span dir="ltr">&lt;<a href="mailto:cliffyapp@gmail.com">cliffyapp@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Is there any way within a CMakeLists.txt file to get a list of all the<br>
currently defined targets?  I&#39;m interested in this for two primary<br>
reasons, and if anyone can point me to other solutions for these that<br>
would be great, but I&#39;m sort of stumped.<br>
<br>
1)  I have a timestamp rule that prints out the time at the start of<br>
the build.  Ideally, I&#39;d like this target to depend on every other<br>
target in the project, so it is always run at the beginning of the<br>
project, but manually specifying dependencies for something like that<br>
is an un-maintainable nightmare.  I&#39;d vastly prefer to (as the last<br>
step in the CMakeLists.txt file) iterate over all targets and make<br>
each of them depend on the timestamp rule.  Unfortunately, so far I<br>
can&#39;t figure out how to do this.<br>
<br>
2)  I&#39;ve been asked to implement a clean rule that removes JUST the<br>
final product of a target (exe file, lib, etc) and not the individual<br>
compiled files that are finally linked to form the product.  If there<br>
is a feature like this in CMake I haven&#39;t found it yet, and the only<br>
way I can think to do this globally (as opposed to adding extra logic<br>
to every single target manually or via wrapper macro) is again to<br>
iterate over a target list, (hopefully) read the product info from the<br>
target properties, and generate a rule based on that.  Does anyone<br>
know of a solution to this sort of custom clean behavior?<br>
<br>
Cheers, and thanks!<br>
CY<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>