NVHPC compiler + Ninja misses header dependencies
With CMake 3.20.1 and nvc++ 21.2 (NVHPC 21.2) then include dependencies are silently not added with the Ninja generator.
This appears to be because the CMake configuration for the NVHPC compiler does not have anything like this to add the -MD
option. This has been supported in NVHPC since at least version 20.9.
A quick and dirty test adding
set(CMAKE_DEPFILE_FLAGS_CXX "-MD<DEP_FILE>")
seems to improve the situation in a small test project.
Adding -MT <DEP TARGET>
, which is documented in nvc++ -help
, seems to modify the name of the target printed to the dependency file (as expected), but causes errors because it apparently stops the compiled object file being written. I am not sure what the downside, if any, of omitting the -MT
option is.
If the Makefile generator is used then dependencies seem to be handled correctly.
I pushed a small demonstrator to https://gitlab.kitware.com/olupton/nvhpc-build-dependencies