In a cmake project on ubuntu, I am trying to use CPPClean to find unused/unnecessary headers for all my targets. However I'm lost how to integrate this in my project.
The usage of CPPClean is
cppclean --include-path=directory1 --include-path=directory2 <path>
I would like to have one target that I can build that does runs cppclean on every target that I mark. Something like:
add_library(foo_target
src/foo.cpp include/foo.hpp)
target_include_directories(foo_target PUBLIC include)
target_link_libraries(foo_target PUBLIC bar)
cppclean(foo_target) #this function adds the target to some kind of global list?
Then the build target that does the cppclean would have to do the following
For all targets that are tagged:
- get all the include dirs of the target
- get all the include dirs of the libs that are linked to
- run the cppclean commmand (which we can assume is installed on the system) on the target main dir with the include dirs that we just determined
Any ideas if this is a descent way to do this? And how would I implement this last part? Especially how do I have one target execute a (unknown) number of commands?