CMake does not build executables and libraries on its own. Instead, CMake configures a project and generates files used by another build tool or framework to build the project. On GNU/Linux and macOS, CMake typically generates Unix Makefiles, but a number of alternatives exist. On Windows, these are typically Visual Studio project files or MinGW or MSYS Makefiles. CMake includes a wide range of generators for native command-line build tools or integrated development environments (IDEs). You can read more about them at the following link: https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html.
These generators can be selected using cmake -G, for instance:
$ cmake -G "Visual Studio 15 2017"
Not all generators are available on every platform and, depending on the platform where CMake runs, typically only a subset is available. To see a list of all available generators on the current platform, type the following:
$ cmake -G
In this chapter, we will not cycle through all the available generators but we note that most recipes in this book have been tested using the Unix Makefiles, MSYS Makefiles, Ninja, and Visual Studio 15 2017 generators. In this chapter, we will focus on developing on/for the Windows platform. We will demonstrate how to build a CMake project directly using Visual Studio 15 2017, without using the command line. We will also discuss how to cross-compile a Windows executable on a Linux or macOS system.