如何使用 Windows 上的 Visual Studio 和 CMake 为 Mac OS X 编译 C++

How to compile C++ for Mac OS X using Visual Studio on Windows and CMake

I read that Visual Studio now supports cross-platform development. I'm using CMake to compile for Windows and Ubuntu (using WSL) so far. However there doesn't seem to be any information on how to actually accomplish the cross-compilation using Visual Studio to target Mac OS X. Is it doable with the CMakeSettings.json? According to this文章,你可以选择Linux-DebugLinux-Release作为configurationType,但在Visual Studio 2017 Enterprise中,Linux选项甚至都没有对我可用,Mac OS X.

也不可用

我可能只是按照 this post 中的建议设置虚拟机,这似乎是完成工作的最方便的解决方案。

显然你不能。

I ended up installing a virtual machine with Mac OS X and successfully compiled my code inside it using shared folders to make my Windows host source code available to the guest. This is certainly more reliable and sane to do than some hacky cross-compilation project。后者仍然不能保证代码会成功运行并且不会在交叉编译目标操作系统上意外崩溃。