'How to find unused files in a CMake C++ project
I have a huge legacy code project that I want to clean up a little. I know for a fact a couple of files are not actually being used. The project is based on CMake. But there are more than 15 targets with lots of dynamic variables containing source file paths, so reading the CMakeLists.txt manually is tricky.
So can I produce a list of unused files automatically after a CMake build?
We should be able to get a list of the used .cpp source files after the build, and I bet we can deduct this from an e.g. find ... command.
Note: here I refer to unused files as source files that aren't compiled into a target. Ideally I would also want the unused .h header files, but I bet that's outside the CMake scope.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
