Graphviz per-target generation fails due to 'Too many open files' on Windows
Generating a dependency graph with the --graphviz option using the default settings fails for some projects with many targets when running on Windows. The output error messages such as the following for some of the targets (here "T_57"), and no per-target files are generated for those targets:
CMake Error: Cannot open file for write: E:/tmp/cmake-test/build_3.17/deps/dep.T_57.tmp
CMake Error: : System Error: Too many open files
CMake Error: Cannot open file for write: E:/tmp/cmake-test/build_3.17/deps/dep.T_57.dependers.tmp
CMake Error: : System Error: Too many open files
The following minimal example can be used to reproduce the issue: graphviz-many-targets.zip
It contains a single executable target that depends on 300 independent library targets.
To reproduce, unpack the archive and run cmake without options to configure a build. Then try to generate the dependency graph. You should be able to observe the problem described above.
The issue exists at least in versions 3.17.3 and 3.18-rc3. It is not present in version 3.16.8.
I suspect that the problem was introduced with the improvements to the Graphviz generation in MR !3766 (merged) .