[CMake] List CMake source files for external use

Kevin Wojniak kainjow at kainjow.com
Wed Sep 25 12:15:53 EDT 2013


Hi, been searching for a while on this and can't find an answer. Maybe I'm just using the wrong keywords..

I have a CMakeLists.txt file that creates a two libraries. I want to generate a list of source files that are used in each library so that I can run a script on these files.

I cannot find a good way to do this. My best idea right now is to move the part of the CMake file that configures the SOURCES variable into a separate .cmake file and run CMake in script mode on that with a flag to output the variable. But that seems slightly hackish, and I don't like separating the file into two.

Is there a better way? How do programs such as Qt Creator go about reading a CMake file and gathering all the source files?

Thanks,
Kevin



More information about the CMake mailing list