Static libraries containing cu files always rebuild with visual studio generator
Minimum repro attached.
When configured using a command line like: "
cmake .. -G "Visual Studio 16 2019" -A X64", the generated visual studio project always rebuilds the TestLibrary static library project, every build. Using detailed output from visual studio you get:
2>------ Up-To-Date check: Project: TestLibrary.vcxproj, Configuration: Debug X64 ------
2>Project is not up-to-date: build output 'testlibrary.dir\debug\empty.obj' is missing
Putting things in the empty.cu file doesn't actually change this and
testlibrary.dir\debug\empty.obj does exist in the project directory.
This appears to because the CompileOut property under CudaCompile in the vcxproj is being set to
$(IntDir)%(Filename).obj, which is a relative path, and is presumably not being interpreted relative to the project directory. Manually changing that to
$(ProjectDir)$(IntDir)%(Filename).obj fixes the issue.
CMake version 3.14.2. Visual Studio version 16.0.3. Cuda compilation tools 10.1, version 10.1.105.