Issue
I am working on a C project which uses a subset of the files taken from other, independent projects. This top-level project has its own CMakeLists.txt which describes what has to be built, including some "subdirectories" from the child projects.
The Explorer is cluttered due to all the files showing, even the ones that are not built by any target.
I think this feature exists for Visual Studio as "CMake filters" (not entirely sure).
Is there a way to automatically hide source & header files that are not used by the project?
Solution
As far as I know, no. What VS Code shows in its Explorer View can't be hidden by an extension (though I might be wrong about this). You can control this using VS Code's builtin mechanisms, such as the files.exclude
setting (though this has more ramifications than just what is shown in the Explorer View).
I'd suggest that you just use the CMake View's "Project Outline" subview (in the Activity Bar) contributed by the CMake Tools extension, which you can also open by using the CMake: Focus on Project Outline View
command in the command palette, which will show you the subdirectory hierarchy known by the CMake project configuration, and the targets in those subdirectories, and the source files of those targets.
Answered By - starball Answer Checked By - Robin (WPSolving Admin)