tomtom-international / cpp-dependencies

Tool to check C++ #include dependencies (dependency graphs created in .dot format)
Apache License 2.0
745 stars 85 forks source link

Make very explicit what the tool does with CMakeLists #48

Open pizzard opened 6 years ago

pizzard commented 6 years ago

I started using the tool on my codebase recently and for some components I could make some improvements already.

But with bigger contexts the tool still struggles. I tried to find out why. As far as I can see, the tool is not able to handle the INCLUDE() Cmake directive correctly, so some crucial targets are missing and my depedency graph is wonky.

Is this support indeed missing? Where would on start adding it?

dascandy commented 6 years ago

The tool does not actually read the cmakefile at all; it uses its presence to mark a folder as a component, and scans it to see whether it's a library or an executable (defaulting to a library if it doesn't find it). The rest of the cmakefiles are completely ignored.

You can try adding empty files called "CMakeLists.txt" in the folders of other components to make it see a component there, or using the "--infer" flag to make it think of each folder with some sources as a component.

One alternative could be to actually read cmakelists, but that would make the tool much more complicated, tie it into CMake for its function, and would probably be fairly fragile by itself.

pizzard commented 6 years ago

That should be added to the documentation, this requires you to have the definition as library or executable inside the cmake file directly and not hidden between further includes. Furthermore it requires you to never defines multiple targets in a CmakeLists.txt. Doesn't sound problematic once I know, would just be nice to add documentation about the expected project layout.

dascandy commented 6 years ago

Changed the description to updating the documentation; for some reason many people think it actually reads the CMakeLists. To be completed together with adding support for other "build-style files" that demarcate components.