I have been working on a cmake project in C++ using vim editor. I want to switch my environment from VIM to visual studio. However, my project does not have sln file. Thus visual studio cannot run the project...?

I do not know how to import my project to visual studio and make it visual studio project.

Can you tell me how to do this?

  • 1
    You can run cmake --help to see a list of available generators. If you have a visual studio generator you can select it with something like cmake -G"Visual Studio ..." . to generate a visual studio project. – super Jun 27 '19 at 16:36
  • Create a new Visual Studio project (there are templates to select from), then add the files and paths to the project. – wally Jun 27 '19 at 16:37
  • @wally I cloned my project from github on VS. I already modified lots of codes (but not tested yet) on visual studio. If i create a new project, my github history is gone (or is there any way to do preserve git history??). – user9414424 Jun 28 '19 at 9:26

This does not depend on the editor you were using but more on build system you want to generate with cmake. I assume you generated makefiles and were running on linux. If you want to use it with visual studio you need to create the sln with cmake by setting the generator to a visual studio compiler version. Just by running cmake -G <your generator> which is in your case the visual studio version you are running.

|improve this answer|||||
  • What I did is cloning via visual studio my github project. How do I do cmake -G?? My first environment is on linux and its cmake does not support cmake -G VS... – user9414424 Jun 28 '19 at 9:24
  • Of course visual studio generators are just available on windows. You can run cmake -G either within any terminal (assuming cmake is installed) and using the cmake gui – FreshD Jun 28 '19 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.