
Explore the course scope of modern CMake, including syntax, targets, libraries, modern project structure, installing basics, refactoring legacy builds, and live coding with dependency management.
Learn to set up a cross-platform environment for CMake, with version 3.20, Ninja, and IDE options like CLion, Visual Studio, or terminal workflows.
Install CMake and Ninja on Windows by downloading the CMake msi and Ninja zip, ensure minimum version 3.20, add their folders to PATH, and use Git Bash for terminal work.
Learn to install and configure cmake and ninja on macOS by downloading cmake (with or without CLion), adding cmake to PATH, and installing ninja-build via brew or manual zip.
Learn to work with Sea Lion to open and configure CMake projects in CLion, manage generators (ninja vs make), build and test targets, and install results.
learn to install multiple compilers on windows and run ubuntu in one project. import configuration, switch between release and ninja generator, and configure the toolkit for windows and ubuntu.
In this lecture I explain how important is understanding cmake_minimum_required() function for project. I also present other functions that should be place in CMake project. Off course having "Hello World" message in first project is compulsory!
Explore how CMake uses generators to produce different build systems from a source directory and build directory, including makefiles, Ninja, and Visual Studio, with notes on when to use each.
In this lecture I present how to declare variable and modify variables values. Off course CMake is CMake, so using variables cannot be too easy. I present also some traps that CMake syntax has for us and how to avoid bugprone situations.
Explore how CMake treats variables as strings and how to use lists with foreach and list() operations, including append, set pitfalls, and variable indirection.
This lecture is short, but it should be, because creating executable in CMake is very easy.
Learn how to add a library to the build system with add_library, choosing static or shared, and link it via a target like MyLibrary, including source and header considerations.
It is not enought to use target base approach over variable based approach. The power of Modern CMake starts to be visible when we introduce good build system structure. In this lecture I explain how to connect targets and add CMake subprojects to have well organized, flexible and effective CMake build system.
Explore cmake project structure variables such as CMAKE_SOURCE_DIR, CMAKE_CURRENT_SOURCE_DIR, CMAKE_SOURCE_DIRECTORY, CMAKE_CURRENT_LIST_FILE, and CMAKE_CURRENT_BINARY_DIR, and learn their differences for portable, subproject-friendly builds.
Conditions topic seems to be easy for every developer that has some experience in programing, but CMake again have a slightly different approach than standard programming languages. Understanding CMake conditions syntax is very important to be able to read the code and find root causes of some bugs.
In this lecture I show a way how we can pass values from CMake build system to source code (eg. C++, C).
When we have multiplatform project and we use shared libraries MSVC (Microsoft Visual Compiler) requires from us to add some changes to source files and build system. In this lecture I show the most optimal solution by using CMake mechanisms that we already know.
CMake Cache is a good mechanism, but there is some traps that wait for developers that are not aware about few things. In this lecture I explain how to use CMake Cache well and show good practices.
The tests are very important part of build system. In this lecture I show another advantage of the modern CMake project structure: adding test applications is very easy.
Learn how to link external libraries with cmake using find_package and Google Test, including configuring, building, and importing installed artifacts for cross-platform projects.
Learn to generate documentation with oxygen from CIMIC by using a pattern-based configuration to substitute project name and version and expose a custom target for generation.
Master target properties in CMake by using set_target_properties and get_target_property to set per-target C++ standard and control output directories.
Enable ctest in your cmake project to run all tests with one command, configure per-test targets, and supply test names, arguments, and working directories for CI.
Learn to manage build types in CMake, handling single and multi-configuration generators, per-configuration flags with custom names, and debug versus release conventions, including target postfixes.
Refactor an existing project with CMake and the Qt framework, configuring the compiler for Windows. Add Qt binaries to the system path and consider the Ninja generator for faster builds.
Review the project structure and build system design, comparing a monolithic approach with a refactored layout using subprojects, external test frameworks, and targeted include directories.
Continue the project refactoring by moving classes to the widgets directory and refining library links, Qt integration, and target structure using find_package with components and version pins.
Polish the CMake project by explicitly specifying languages and version, setting module paths, and using per-target compiler flags instead of broad refactoring that merges libraries.
For many developers CMake is not so intuitive, eg. because of the syntax. Others are able to see CMake documentation, but miss good practical examples. After more than 10 years of experience in programming and leading many CMake workshops I was ready to prepare multiplatform friendly course for beginners in CMake world and also for people that has experience in CMake that will help to solve that problems.
There is many tutorials and blog posts, so why this training? In this training I put not only theory that you can find in the popular websites, but firstly I present:
good practices from first lecture
how to avoid making simple but hard to find mistakes
advantages and disadvantages of many solutions
This training is the first part of series "Effective Modern CMake".
In this training I try to avoid the command line that is usually good, but platform dependent, so never mind if you are using Windows, Linux or macOS. This training is for you. Moreover I show differences and in some topics dedicated solutions for each platform if it is needed. I prepared videos that help you setup environment in the most popular code editors like CLion, Visual Studio and Qt Creator. Of course you can use your favorite IDE.
Would you like to have an example of given topic, eg. integrating with C++ library? Put a comment and collect the vote!