Another Update and Project Files Were Broken Again

I had everything working fine with v11.6.0. Then I installed 11.6.1, then 11.6.2, 11.7 and my project files broke with all of them. There were two problems and I fixed both of them. My environment is Windows 10 and Visual Studio 2019.

First was the fact that all of the sample projects I tried would not build because it couldn’t find the 11.6 build property files. My projects had the same problem. To deal with this I added an environment variable I called CUDA_VERSION and set it to 11.7. I changed my project files in two places to use these lines :

  <ImportGroup Label="ExtensionSettings">
    <Import Project="$(CUDAPropsPath)\CUDA $(CUDA_VERSION).props" />
  </ImportGroup>

  <ImportGroup Label="ExtensionTargets">
    <Import Project="$(CUDAPropsPath)\CUDA $(CUDA_VERSION).targets" />
  </ImportGroup>

Note that this uses the CUDA_VERSION EV that I had made instead of using the literal CUDA version. This lets the same project file work with practically any version of CUDA.

The other problem is the CUDA .props file ignores the project’s intermediate directory configuration. I have reported this as a bug but the powers that be disagree with me. Here’s how you can make the CUDA compiler use the intermediate directory that YOU want.

The problem is this line in CUDA 11.7.props :
<CompileOut>$(CudaIntDirFullPath)\%(Filename)%(Extension).obj</CompileOut>

I changed it to :
<CompileOut>$(IntDir)%(Filename)%(Extension).obj</CompileOut>

and then the intermediate directory I configured for my project in VS will be used instead of the default directory.

Note - the CUDA 11.7.props file is in (VisualStudio)/MSBuild/Microsoft/VC/v160/BuildCustomizations for VS2019.

Let me say that I was bitten by this right now when I tried working with 11.7 and I also disagree with NVIDIA’s decision to have their own intermediate directory for CUDA compiler.

Dear NVIDIA, your compiiler is an integration into Visual Studio, not a standalone product – you cannot just decide not to respect $(IntDir) set by the developer and litter the project directory with your own folder structure and file placement.

Intel’s C++ Compiler respects $(IntDir), and so should you. If there is a potential conflict in file naming, then just change the extension – instead of foo.obj call the file foo.cuobj or even better let the developers worry about that. I am sure we can handle that.