
Master modern CMake and boost your development skills by learning the most popular project generator, writing your first script within the first 30 minutes, and configuring projects with production templates.
In this video I will tell you some common information about online learning in general and how to have a great course experience.
I will update this with answers to commonly asked questions.
In this video, I shortly introduce the course and the sections.
In this short video I show you how to install everything needed to follow the main part of this course.
This article provides you with links to all of the tools that I might use throughout the course.
This is a short introduction to what we will be learning in this section.
An overview of the compilation process of C++ programs. Will be useful later for understanding different settings that we control with CMake as well as cross-compilation settings that we will use later.
Here I show you how a typical Visual Studio project is set up. I focus on the project management part and not on the actual source editing experience. Keep in mind that this is the nicest and most visual of the systems that allow you to manage a C++ project. Makefiles are even harder to manage.
A brief description of the role of CMake in managing your project.
A command line basics tutorial that you would need to know to follow along with the rest of this course.
Here I show you how you can setup 3 of the IDEs available for C++ development. These are VS Code, Visual Studio 2022 and CLion.
A little more info on how to follow through the course if no matter if you choose an IDE or not.
We write our first CMake code in the typical programming "Hello, World!" example.
Summary and brief on what is to follow.
Revisit the hello world example to illustrate CMake commands and arguments that control project configuration. Show how commands use brackets and strings, handle whitespace, and include comments with hashtags.
Learn cmake conditions and boolean variables to drive conditional configurations. Use if/endif with else and elseif, and operators like and, or, not, as well as list and string comparisons.
Explore how cmake functions and macros create commands and handle arguments with argv, argn, and parent_scope. Learn about scope differences and why functions impose a scope while macros do not.
Learn to build robust cmake custom commands by parsing arguments with cmake_parse_arguments, handling options like warning, single and multiple values, and message output prefixes.
Use the include command to modularize CMake by moving functions into separate .cmake files and including them from the main CMakeLists.txt, keeping builds clear and maintainable.
Master CMake configuration and scripting by defining variables and commands, and control flow with conditionals and loops. Organize code across parts to generate and build projects.
Discover how to compile different targets in CMake, including executable, library, and custom targets, and manage dependencies with include directories and public versus private linking.
Learn to structure a CMake project with dedicated include and src folders for private and public headers, organize subdirectory targets with add_subdirectory, and map build outputs per target.
Learn how to manage CMake sources with glob_recurse to auto discover headers and sources, compare per-file listing with globbing, and understand configure_depends option and build implications.
Discover how to use CMake glob_recurse and loops to automatically capture example sources, declare each as its own executable, and build multiple examples in a single project.
Define boolean options to control builds, such as building examples, which are cached per configuration, and learn to change them by deleting the cmake cache or using -D build_examples=true.
Discover how to configure a cmake project using the cmake gui, including setting build directories, choosing a generator like Visual Studio, and reconfiguring without the command line.
Define precompiler definitions in cmake by using target compile definitions, replacing global options, and leverage generator expressions to toggle symbols like my_debug for debug versus release builds.
Learn to modify compiler flags in cmake with target compile options, handle gnu vs msvc differences, and use check cxx compiler flag to validate flags and know about linker options.
Learn about cmake toolchains, simple script files that configure the compiler. Set the toolchain file path with a command line variable for cross-compiling, including Linux examples.
Master building projects with CMake by defining targets, configuring compiler and linker settings, pre-compiler definitions, and including source files, while learning to manage external dependencies.
Learn to manage dependencies in cmake by adding subdirectories and interface libraries to link raylib with your project, and configure options to build examples.
install and use vcpkg, a cross-platform package manager, to install raylib via cmake, manage triplets (such as x64-windows), and integrate libraries with find_package.
Master external dependencies management and package manager integration within your project, applying what you learned for daily CMake usage.
Compile C++ to the browser with cmake and emscripten, producing JavaScript and wasm. Set up emsdk, ninja, and the emscripten toolchain, configure cmake, build, and test with emrun.
Explore compiling for the web, master cross-compiling, and apply the same CMake-based setup to embedded platforms.
Create custom targets in CMake to run your own tools, copy data with a Windows batch file, and manage dependencies like exe and move data while handling working directories.
Learn how to integrate C++ code as part of the build with cmake, replacing platform-specific scripts with a cross-platform copy executable run step that builds before the main target.
integrate python scripts into a cmake build as a platform-neutral solution. learn to locate python 3 with cmake and use the interpreter variable to enable cross-platform builds.
Learn how to customize your build through scripts and automate your build to manage projects beyond the code.
Learn to use ctest, the cmake integrated testing tool, for simple unit tests. Configure tests with add test and run from the build directory; a zero return code signals success.
Learn how to integrate the Catch2 test framework with CMake, clone it from git, enable Catch2 with main, configure via CMake, and run tests with ctest.
Learn how to use Google Test in a CMake project, linking GTest, enabling GTest discover tests, and running tests with ctest while exploring CMake and test framework abstraction.
Run ctest as a build step to execute unit tests during compilation, using a custom target all tests in cmake and the google test framework to reveal failures or successes.
Reviews:
"Awesome course. I wanted to learn CMake a long time ago, but every time I tried to learn, I just felt overwhelmed by the sources. This course gives a really good step-by-step approach, with a good didactic." - Andre Aranha
"Totally recommend this course; the mentor teaches each and ever aspect of CMake also he answers every query"—Million Stinger_S
"Very knowledgeable instructor! If you're interested in C and/or C++, even as a hobby, you'll need to learn CMake. This course covers everything you need to start and work on both small and large projects. It includes topics like dependency management, testing, and packaging. You can't go wrong with this one." - Fellipi Carmo
"The course is suitable for beginners and advanced users who want to improve their CMake knowledge." - Victor Stoykov
Description:
This course is all about CMake. CMake is an application that helps you structure C/ C++-based native projects, generate build commands for the target platform, build your application, pack it into an installer, install it, test it, and it will even help you with managing your dependencies.
In this course, you will learn:
How to use CMake to structure and compile your C/C++ projects
How to manage your dependencies
How to get your project compiled for the web using Emscripten
How to include unit tests and test your application
How to customize the build pipeline with your own tools (if you want to do your own custom build steps)
How to compile other projects that support CMake and even ones that do not
How to install and package your project
Bonus snippets include some advanced setups like documentation using Doxygen
In the end, you will have all the knowledge needed to be able to open up a random CMake project and compile it yourself. You will also be able to confidently start and write your own CMake scripts for your projects. This will elevate your programming experience with the low-level C/C++ languages, and it will also simplify a lot of the hard concepts related to those languages.
This course is primarily taught on the Windows OS, but the knowledge gained can easily translate into other operating systems as well.