CMake for Visual Studio Developers

Visual Studio projects are not human readable as such with its excessive XML tags. The layout is more machine friendly. The UI (Project->Properties) to modify the project file is rather clunky too. Finding options in the various tabs and tree items can be a challenge. Very often, trying to figure out changes made as part of a commit in a source control tool is a nightmare. CMake on the other hand gives the flexibility to organize, and it being simple text, viewing commit differences is just like source code.

Compatibility between different versions of Visual Studio is quite messy too. Its high maintenance if you have to deal with multiple versions of Visual Studio. CMake provides a neutral interface independent of Visual Studio nuances between versions. It is not only useful to manage multiple versions of Visual Studio but is a good tool to create a cross platform build system.

However, for someone from a Windows only Visual Studio development environment (with not much experience with Linux and classic Makefile) CMake can be a little intimidating. The language is much more “friendly” to those familiar with Linux style scripting. The documentation though quite detailed, is difficult to parse until you know the basics and know what to look for. Being able to map the CMake commands to the Visual Studio IDE makes learning much easier.

Having spent some time to understand the fundamentals and the relation with Visual Studio, I’ve documented it with an example and will hopefully help other developers jump start using CMake.

See CMake and Visual Studio for more details.