The code for this recipe is available at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-13/recipe-01 and has a C++ example. This recipe is valid with CMake version 3.5 (and higher) and has been tested on GNU/Linux and macOS.
In this recipe, we will reuse the "Hello World" example from the previous recipe and cross-compile the code from Linux or macOS to Windows. In other words, we will configure and compile the code on Linux or macOS and obtain an executable for the Windows platform.