问题
I have have a CMake project, which I sometimes I need to build/debug on Linux. I've tried using "Linux development with C++" to connect to my Virtual Debian machine, but it doesn't work the way I want.
It don't want to create a new project, I only want to generate a makefile using CMake and connect to it.
https://blogs.msdn.microsoft.com/vcblog/2017/04/11/linux-development-with-c-in-visual-studio/
I've tried to read this, but it doen't tell how to connect to an existing project.
回答1:
I only want to generate a makefile using CMake
You can check out in Properties->General->Project Defaults->Configuration type to use existing makefile.
Here microsoft gives you nice guide on how to make use CMakeLists.txt file in Visual Studio 2017.
In short you need to
- Open your CMakeLists.txt and source files(No need to create new project for this, just do open folder)
- Choose Linux target in Tools > Options > Cross Platform > Connection Manager
- Configure CMake settings for Linux by right-clicking CMakeSettings.txt in Solution Explorer and choose Change CMake Settings. It is saved as a CMakeSettings.json file in your project folder
When building, the source files on your development PC are copied to the Linux computer and compiled there.
Please not that it requires Visual Studio 2017 version 15.4 and later.
Also, CMake support in Visual Studio requires the server mode support that was introduced in CMake 3.8. You can get Microsoft provided CMake from here
来源:https://stackoverflow.com/questions/53664808/build-existing-c-solution-on-linux-using-visual-studio-2017