Support custom Object file name in Visual Studio generator

I generate Visual Studio projects from cmake and use them for development in the Studio. Now I want to run build cache tool (GitHub - mbitsnbites/buildcache: A build cache) to speed my build times.

The tool requires to set object file names to $(IntDir)%(Filename).obj instead of $(IntDir), so compiler is invoked for each file.

So I tried to add target_compile_options for my cmake target with /Fo$(IntDir)%(Filename).obj and it adds <ObjectFileName>$(IntDir)%%(Filename).obj</ObjectFileName> element to the generated vcxproj file. But then there is one more ObjectFileName element added: <ObjectFileName>$(IntDir)</ObjectFileName>

Is it ok to fix the visual studio generator to make it not generate the second ObjectFileName and send pull request?

Note that CMake generally needs to know the output path so it can hook up dependencies, but maybe Visual Studio is more relaxed here. @brad.king, how feasible is this?

CMake does need to know the object file names and paths exactly in order to implement OBJECT libraries. I don’t recall if they need to be known for anything else. So long as CMake can predict the object file paths, it shouldn’t matter how they are represented in the .vcxproj files.

@kdonev to make your proposal concrete, go ahead an open a merge request. We can review the details there and then decide whether it’s feasible.

Please, review my request