Installing a C++20 module fails with Visual Studio generator
I have a test project which builds successfully on Windows with both Ninja and the Visual Studio 2022 generator. It also installs successfully with Ninja, but the Visual Studio generator fails to install with an error similar to the following:
CMake Error at cmake_install.cmake:144 (file):
file INSTALL cannot find
"C:/Users/craig/Projects/cxxmodules/module_producer/build-msvc/CMakeFiles/Export/22ecfa717ccadd33cf3e4bcbabcbde6b/modules/target-foo-Release.cmake":
File exists.
It appears that the target-foo-Release.cmake
file isn't created for the Visual Studio generator. With the Ninja generator, it gets created at build time. Not sure what in the build process is responsible for its creation, but this seems like a bug in the Visual Studio generator somewhere.
FWIW, if I copy the target-foo-Release.cmake
file from the working Ninja build and put it where the Visual Studio build expects it to be, the install step works. In a separate consuming project, it can successfully find and use the installed producer project if I use the Ninja generator in the consumer, but again the Visual Studio generator fails. I think this part is due to features not yet implemented for the Visual Studio generator (a known limitation). I mention this only to demonstrate that the install with Visual Studio generator appears to be good enough if this file was actually created.
I have attached the projects I'm using. They could be simplified a little further to make a more minimal demonstrator, but it's a handy pair of projects for investigating some other modules behavior (e.g. #25539). It's still pretty small, so hopefully good enough for demonstrating the problem described here.
I was using CMake 3.28.1, Ninja 1.11.1, Visual Studio 2022 (17.8.4).