If you develop software only on Windows using Visual studio, it’s a luxury. Enjoy it while it lasts. Sooner than later, you will come across
Makefiles, maybe exploring some software on Linux or the misfortune of having a build system that uses
Cygwin on Windows.
Now you figure out that
Makefiles are text files and open it in an editor hoping to get some insight into its workings. But, what do you see? Lots of cryptic hard to understand syntax and expressions.
So, where do you start? Internet searches for
Makefiles provide a lot of information but under the assumption that you come from a non-IDE Unix/Linux development environment. Pampered Visual Studio developers are never the target audience.
Here I will try to relate to the Visual Studio build system which will hopefully give an easier understanding of
Makefiles. The goal is not provide yet another tutorial on makefiles (because there are plenty available on the internet) but to instill the concept by comparison.
See Makefiles and Visual Studio for a Visual Studio friendly introduction to the Make utility.
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.