Reputation: 1393
I have a big project already building under cmake. I am looking for a way to obtain the list of source files and their dependent header files to create a new target (in example etags for Emacs). I tried to find the answer on my own but it seems to not be that easy.
The ideal soultion would be something like that:
add_executable(my_project <some list of source files and libraries defined in different directories>)
add_custom_target(tags
COMMAND etags <list of all *.cpp and *.h files used in 'my_project' target>
DEPENDS <list of all *.cpp and *h used in 'my_project' target>
COMMENT "Creates source code tags for Emacs")
Do you maybe know how to make 'tags' target import all dependencies from 'my_project' target without the need to rewrite all cmake configuration files in all directories?
Upvotes: 11
Views: 15534
Reputation: 4010
With command get_target_property
and property SOURCES and eventually PUBLIC_HEADER or PRIVATE_HEADER?
get_target_property(MY_PROJECT_SOURCES my_project SOURCES)
Upvotes: 16