[CMake] target lists

James Bigler bigler at cs.utah.edu
Mon Nov 26 13:53:26 EST 2007


> Is there a way to get a list of all the targets in a given  
> project?  I need to get a master list of libraries, and I can't  
> pass global variables up without some intimate knowledge of all the  
> directories where libraries were added.

Well, part of the solution is to replace ADD_LIBRARY with my own  
macro that will call ADD_LIBRARY with some other machinery that set a  
global variable.  I had to make this an internal cache variable to  
get the variable to propagate up through directories.

   SET(temp_library_list ${SCIRUN_LIBRARY_LIST} ${library})
   SET(SCIRUN_LIBRARY_LIST ${temp_library_list} CACHE INTERNAL "List  
of all libraries")

I found this little trick from this posting:

http://www.cmake.org/pipermail/cmake/2005-September/007204.html

------------------------------------------
I'm wondering still if there is a way to get a list of all the  
targets without having to resort to this kind of hackery.

Thanks,
James


More information about the CMake mailing list