In the final chapter of this book, we will combine a number of different building blocks that we have discussed in the previous chapters and apply them to a real-life project. Our goal will be to demonstrate step-by-step how to port a non-trivial project to CMake and discuss the steps involved in such a process. We will provide recommendations for porting your own projects or adding CMake support to legacy code, be it from Autotools, from hand-written configure scripts and Makefiles, or from Visual Studio project files.
To have a tangible and realistic example, we will use the source code behind the popular editor Vim (https://www.vim.org) and attempt to port the configuration and compilation from Autotools to CMake.
To keep the discussion and the examples relatively simple, we will not attempt to present a full port to CMake for the entire Vim code with all options. Instead, we will single out and discuss the most important aspects and only build a core version of Vim, without support for a graphical user interface (GUI). Nevertheless, we will arrive at a working version of Vim, configured, built, and tested with CMake and the other tools we have presented in the book.
The following topics will be covered in this chapter:
- Initial steps when porting a project
- Generating files and writing platform checks
- Detecting required dependencies and linking
- Reproducing compiler flags
- Porting tests
- Porting install targets
- Common pitfalls when converting projects to CMake