Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Modern CMake Hands-On: Build, Test, Package, Cross-Compile
New
4 students

Modern CMake Hands-On: Build, Test, Package, Cross-Compile

Break real C/C++ builds on purpose, then fix them in VS Code: targets, CTest, CPack, ARM cross builds, remote debug
Created byYungKi Hong
Last updated 11/2026
English
English

What you'll learn

  • Write CMakeLists.txt files from scratch and explain every line, instead of copying them from other projects
  • Diagnose failed builds by reading configure and build logs, including version and policy errors in older projects
  • Structure libraries and executables as targets with correct PUBLIC, PRIVATE, and INTERFACE usage requirements
  • Ship shared libraries that keep working: symbol visibility, SONAME versioning, and RPATH
  • Switch build variants with options, cache variables, generator expressions, and CMakePresets.json
  • Bring in third-party code with find_package and FetchContent, and run unit tests with CTest and GoogleTest
  • Produce installable TGZ and DEB packages from your install rules with CPack
  • Cross-compile for 64-bit ARM Linux, run it under QEMU, and debug a remote target from VS Code with gdbserver

Course content

9 sections • 26 lectures • 6h 11m total length
  • Course Introduction1:41
  • Lab Setup: Ubuntu, VS Code, and CMake13:33
  • Why CMake? Make vs. CMake and Out-of-Source Builds14:26
  • The Build Flow: Configure, Generate, Build, and the Cache14:50
  • The VS Code Dev Loop: Presets, Diagnostics, and Debugging13:11

Requirements

  • Basic C or C++ programming
  • Basic Linux terminal commands (cd, ls, mkdir)
  • An Ubuntu 22.04 PC or virtual machine. The course uses CMake 3.22, gcc 11, and VS Code
  • No board required. Cross-compilation runs under QEMU on your PC; a Raspberry Pi (3B+ or newer, 64-bit OS) is optional for one lecture

Description

This course contains the use of artificial intelligence.

Your project builds on your machine. Then a teammate clones it and it fails. You add one library and the link step breaks. A tutorial's CMakeLists.txt stops at the configure step on a newer CMake. Most CMake pain comes from the same place: build files that were copied, not understood.

This is a hands-on course in modern, target-based CMake. Every lecture opens a real C or C++ project in VS Code, changes it, builds it, and checks the result in the terminal. Many lectures break the build on purpose first, so you see the exact error a real project would give you, then trace it to its cause and fix it.

What makes this course different

  • Real builds, real logs. You read the Configure and Build output instead of trusting a green checkmark, so the skills survive tool and extension updates.
  • Break it, then fix it. Turn PUBLIC into PRIVATE and watch a header disappear. Drop the RUNPATH and watch a program refuse to start. Remove a DEPENDS line and watch a generated file go stale. Then fix each one and prove the fix.
  • Verified with the tools professionals use. Generated files, binaries, and symbols are inspected with nm, readelf, ldd, and file, not guessed.
  • One project, all the way to release. The capstone takes a three-layer project from a native build to a cross-built, installed, and packaged release.
  • Cross-compilation without extra hardware. ARM Linux builds run under QEMU on your PC. A Raspberry Pi is optional and appears in one lecture to show the same flow on a real board.

Course structure (25 lectures, about 6 hours)

  1. Setup and the build flow. Ubuntu, VS Code, and CMake; why CMake replaces hand-written Makefiles; configure, generate, build, the cache, build types, Ninja, and compile_commands.json; the VS Code edit, build, debug loop.
  2. Targets. Static libraries, usage requirements, and multi-module projects with add_subdirectory.
  3. Shared libraries and options. Symbol visibility, option and cache variables, -D, and generated configuration headers with system checks.
  4. Build control. Generator expressions, function and macro, and CMakePresets.json.
  5. Generated files and distribution. Custom commands, install rules with components and DESTDIR staging, and find_package with exported package configs.
  6. Dependencies, tests, packages, and ABI. FetchContent, CTest and GoogleTest, CPack, SONAME and RPATH.
  7. Cross-compilation. Toolchain files, sysroots, external libraries, and cross testing.
  8. Remote development. Cross build, deploy, and debug from VS Code with gdbserver, on QEMU or a real Raspberry Pi.
  9. Capstone. Everything combined in one project, from first build to release package.

What you get

  • English captions on every lecture
  • Downloadable lab files: every example project, plus written solutions and complete solution projects for the exercises
  • A PDF course book that follows the lectures, with appendices on built-in variables, an optional MCU firmware build, and Raspberry Pi setup

Requirements

Basic C or C++ and basic Linux terminal commands. An Ubuntu 22.04 PC or virtual machine; the course uses CMake 3.22, gcc 11, and VS Code. No board is required.

Not covered

Visual Studio and Xcode generators, package managers such as Conan and vcpkg, CI pipelines, and new CMake 4.x features. The concepts carry over, and one lecture shows how to fix older projects that fail to configure on CMake 4.

Who this course is for:

  • C and C++ developers moving a Makefile-based project to CMake
  • CMake beginners who copy CMakeLists.txt files but want to understand how they work
  • VS Code users who want editing, building, testing, and debugging in one connected workflow
  • Developers who want one path from library design through testing, installation, and packaging
  • Intermediate CMake users ready for cross-compilation, ABI management, and remote debugging
  • Anyone who keeps hitting CMake errors when building open-source C/C++ projects