Search code examples
visual-studio-2010visual-studiocmakeprojects-and-solutions

Add files to cmake project in Visual Studio 2010


I've been using cmake in linux for a while now, but I needed to move over to working in Visual Studio for a few reasons...

I have the cmake project generated, and I can load up the solution in Visual Studio, but when I try to add a file, it gets added to to location of the build files, rather than into the source directories. Is there any way around this, or do they have to be added through Explorer, then regenerate the cmake build files, and then re-open the solution? This seems a tad clunky, and I was hoping for an easier method.


Solution

  • To add the new file via Visual Studio, you can select the "Add -> New Item" option. In the resulting window, there should be a "location" text input box. This has the build directory specified by default, but the path can easily be changed to somewhere in your source tree.