I have a CMake project that creates a DLL from C++ and a C# Windows Forms executable that loads the DLL.
I use the CMake generator: Visual Studio 15 2017 Win64
No matter what I do (one example would be setting compile option: /platform:anycpu), I cannot get CMake to not have the compile flag: /platform:anycpu32bitpreferred.
When I opened up the generated VS project in VS2017, it has the "Prefer 32-bit" flag set in the build options.
Is there any way to force CMake to generate my C# project without this flag set? It is causing run-time linking issues unless I use a 32-bit DLL.
This problem looks to be part of a bigger issue in CMake: https://gitlab.kitware.com/cmake/cmake/issues/17521
I have found a workaround, which is to set the following environment variable before building:
However, the draw back is that this is set for the entire build, and not per-project.