smanders / externpro

build external projects with cmake
MIT License
13 stars 12 forks source link

'make graph' enhancements #344

Closed smanders closed 2 years ago

smanders commented 2 years ago

it would be useful to have a cmake option to disable/remove private dependencies from make graph, which utilizes graphviz to generate a .dot file

if XP_GRAPHVIZ is ON (it is by default) then introduce an option XP_GRAPHVIZ_PRIVATE_DEPS which defaults to ON (shows private dependencies by default), but when turned OFF will remove the private dependencies from the .dot file

smanders commented 2 years ago

CMakeGraphVizOptions https://cmake.org/cmake/help/latest/module/CMakeGraphVizOptions.html

article: "Simplifying your C/C++ dependency graph (with CMake)" http://www.stablecoder.ca/2019/03/15/sorting-you-dependency-graph.html

Delete Lines in a Text File That Contain a Specific String https://www.baeldung.com/linux/delete-lines-containing-string-from-file

sed, a stream editor https://www.gnu.org/software/sed/manual/sed.html

smanders commented 2 years ago

maybe the new graphPvtClean.sh.in https://github.com/smanders/externpro/blob/1927e4820de178e8dd8ce5879a4f17b4e4b57701/modules/graphPvtClean.sh.in needs to detect if sed is available when the script is run (runs at build-time, so detecting it is available in git bash on Windows at cmake-time is not enough), but for now the graph custom target only exists if dot is found and the graphPvtClean.sh script is only run if the XP_GRAPHVIZ_PRIVATE_DEPS is OFF, so I'm not too worried about failures on Windows -- if I hear from developers that they have dot installed on Windows and it's in their path and they're building a project that turns XP_GRAPHVIZ_PRIVATE_DEPS OFF and they are trying to run the GRAPH project I may need to add some logic to the script so it doesn't remove the private dependencies via sed if sed isn't found in the Windows PATH

smanders commented 2 years ago

completed with commits to dev branch referenced above

smanders commented 2 years ago

while I was verifying that some of these new cmake options only show up if advanced is toggled on, I decided to also mark XP_CMAKE_REPO_INSYNC as advanced https://github.com/smanders/externpro/commit/b59ca96fcb9b759820bb4a20a77d02c344d556ab -- so it only shows up now if advanced is toggled on -- I figured projects that are using XP_CMAKE_REPO_INSYNC are stable enough that there should be very rare occasions that a developer should be turning this option OFF and only showing this cmake option when advanced is toggled on clears up some of the clutter when you're looking at the basic cmake options