compile_commands.json should be included in Ninja list of files generated by configuration
I'm trying to write a rule that runs clang-tooling based commands whenever the source files or options change. Completion is tracked by a witness file that gets touched when the tooling runs, but to rerun if the options change this command should depend on the compile_commands.json. However, CMake rejects this with
CMake Warning (dev): Policy CMP0058 is not set: Ninja requires custom command byproducts to be explicit. Run "cmake --help-policy CMP0058" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
This project specifies custom command DEPENDS on files in the build tree that are not specified as the OUTPUT or BYPRODUCTS of any add_custom_command or add_custom_target:
I think the needed fix would be to have cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies include compile_commands.json in knownDependencies when CMAKE_EXPORT_COMPILE_COMMANDS is true. This seems like it would fit here, as the comment describing this section is
// get the list of files that cmake itself has generated as a
// product of configuration.