CMake is a popular open-source, cross-platform family of tools designed to build, test, and package software.
In this lesson we will motivate the use of Make and CMake discover and apply various CMake building blocks. We will exercise applying the material by configuring and building an example mixed Fortran-C++ project using CMake.
The material is not well tested on Windows because the lesson authors are Linux/Mac people. Corrections and contributions which make the lesson more general and portable are very much welcome.
You need to install CMake, as well as Fortran, C, and C++ compilers.
To appreciate this material it helps to have some prior exposure to Makefiles and compiled languages but we have also something for the Python/R crowd.
30 min | Data processing pipeline using Make |
Why do many projects use Makefiles?
How does the make command work? What are Makefiles composed of? Why are Makefiles useful for Python and R developers? |
5 min | Why CMake? |
I am already using Makefiles, do I need CMake?
What are typical problems with Makefiles? Why CMake and not Autotools? I am a Python developer, is any of this relevant for me? |
20 min | Hello-world example using CMake |
How are CMake projects configured and built?
What is an out of source compilation? |
10 min | Exercise 1: CMake-ify a Tetris game | How to configure and compile a code that you found on the net. |
5 min | Help | Where can I find help? |
5 min | Compilers and compiler flags |
How can we select the compiler?
How can we change compiler flags? |
55 min | Exercise 2: CMake-ify an example project |
What is a typical layout for a CMake framework?
How can we build static and shared libraries? How can we get version information into the binary output for reproducibility? How does testing work in CMake? How can we create an installer and packager? |
5 min | Generators | Can CMake be used with tools and frameworks other than Makefiles? |
5 min | Conclusions and outlook |
What can we take home?
Any critical views? What have we skipped? |