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?
A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e , and set(var "a b c d e") creates a string or a list with one item in it.
This specifies the list of paths to source files for the target. The following commands all set or add to the SOURCES target property and are the usual way to manipulate it: add_executable() add_library()
A CMake-based buildsystem is organized as a set of high-level logical targets. Each target corresponds to an executable or library, or is a custom target containing custom commands.
With command get_target_property
and property SOURCES and eventually PUBLIC_HEADER or PRIVATE_HEADER?
get_target_property(MY_PROJECT_SOURCES my_project SOURCES)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With