I'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'd have to name them something different and then change all of your CMakeLists to use your form, but it'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's not very useful.)
Ceej aka Chris Hillery On Sun, Sep 5, 2010 at 3:51 PM, Clifford Yapp <cliffy...@gmail.com> wrote: > Is there any way within a CMakeLists.txt file to get a list of all the > currently defined targets? I'm interested in this for two primary > reasons, and if anyone can point me to other solutions for these that > would be great, but I'm sort of stumped. > > 1) I have a timestamp rule that prints out the time at the start of > the build. Ideally, I'd like this target to depend on every other > target in the project, so it is always run at the beginning of the > project, but manually specifying dependencies for something like that > is an un-maintainable nightmare. I'd vastly prefer to (as the last > step in the CMakeLists.txt file) iterate over all targets and make > each of them depend on the timestamp rule. Unfortunately, so far I > can't figure out how to do this. > > 2) I've been asked to implement a clean rule that removes JUST the > final product of a target (exe file, lib, etc) and not the individual > compiled files that are finally linked to form the product. If there > is a feature like this in CMake I haven't found it yet, and the only > way I can think to do this globally (as opposed to adding extra logic > to every single target manually or via wrapper macro) is again to > iterate over a target list, (hopefully) read the product info from the > target properties, and generate a rule based on that. Does anyone > know of a solution to this sort of custom clean behavior? > > Cheers, and thanks! > CY > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake >
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake