
Target C and C++ developers to optimize build processes and master CMake and C++ build systems. Tackle cross-platform development and porting projects with CMake proficiency across environments.
Note: VSCode setup and useful plugins to install are explained in the Lecture as and when required!
WSL Installation Live Demo: Experience the seamless integration of Windows Subsystem for Linux (WSL) with a live installation demo. Learn how to run the same code written on macOS effortlessly on Linux (WSL), demonstrating the true cross-platform capabilities of CMake."
Download the attached PDF for quick VS Code setup instructions.
Download the attached PDF for quick Git setup instructions.
Explore CMake as a cross-platform, open-source build system generator that creates platform-specific build files for Windows, Mac, and Linux.
CMake enables cross-platform, portable code across Windows, Mac, and Linux, supports Make, Ninja, and MSBuild, and streamlines large project management with IDE integration for efficient incremental builds.
CMake expects a source file and a cmakelists.txt; provide these, and it performs configuration, generation, and the build stage to create executables or libraries.
Discover how to write a minimal cmake project with a CMakeLists.txt, including cmake minimum required version 3.25 and a hello message, while exploring configuration, generation, and build stages.
install and uninstall cmake across macOS, Windows, and Linux, download the 3.30 release from cmake.org, validate with cmake --version, and update your path.
Understand the possible outputs of a C or C++ program, including executables and dynamic or static libraries, with cross-platform naming and cmake guidance for r_executable and r_library.
Learn how to generate a binary executable with CMake by creating a first CMake program, setting the minimum CMake version to 3.30, and building from mod one.cpp.
Demonstrates creating a simple c++ program in macOS with Visual Studio Code, writing mod one.cpp using iostream and cmath, and configuring cmakelists.txt to build an executable.
Navigate the three CMake stages—configure, generation, and build—by configuring and generating build files, then building with CMake --build in a dedicated build directory to run the executable across platforms.
Explore configuration, generation, and build workflows in cmake, including linking, makefiles, and the role of cmake files during error handling and executable creation.
Explore a high-level multi-module cmake plan to generate executables, static and dynamic libraries, and interface libraries across Windows, macOS, and Linux, with demos and on-demand tool installations.
How to download/clone our source code
CMake Guide-Follow previous lecture: `CMake Installation-uninstallation`
VSCode & VS2022 Installation in Windows.
Download source code from Git. Use tags in Git.
Build the project in Windows with CMake Ver 3.25. Understand why CMAKE_MINIMUM_VERSION_REQUIRED()
Installation of g++, CMake using `apt get`.
Installation on the fly and demo the executable generation on Linux(WSL-Ubuntu 24.04)
Getting the CMake version 3.28. We will update the version to 3.30 later in this course. I'll demo how to.
What is planned for next with the timeline!
Uninstall CMake 3.25 and Install 3.30 in Windows
Demonostrate the same code using CMake 3.30.
Uninstall previously installed CMake V3.28 & Install 3.30
Run the CMake & test our existing code
Understand why we use cmake_minimum_required(VERSION)
Building multiple sources to a single executable. Use regular expressions kind of trick to detect all source and header files to build.
Create a cross-platform static library with CMake by defining a library target and supplying src/module_two.cpp, then build to produce a .a archive on macOS, Windows, and Linux.
Master building and testing a static library with cmake by compiling test module two.cpp in the test folder, linking to the library via target_link_libraries, then configuring and building the executable.
Master library generation and use CMake by organizing headers in include and sources in source directory, applying header guards or pragma once, and configuring include paths to avoid missing files.
Configure CMake builds by specifying target include directories, exploring public, private, and interface scopes, resolving build errors, and demonstrating creation and use of a static library.
Explain the scope of CMake target link libraries, showing that public, private, and interface can be optional, and that the target include directory is mandatory. Preview dynamic library generation.
Learn to generate a static library in Linux with CMake: configure, build, and link a test library named lib<name>.a across Linux, Windows, Mac, and WSL.
Theory: How to generate a Dynamic Library or Shared Object.
- Why the flag is in uppercase?
- Dynamic Lib Demo on MAC
In this Linux demo, learn to build a dynamic library with CMake, run a test executable, and address runtime shared library loading issues, with Windows demo to follow.
- DLL linking issue in win
- Need of Import Library
- Generation of Import Library using cmd line.
- Successful build and link of DLL in Windows OS.
Remove .lib=>No effect on executable
Remove .dll=>Afects executable
Introducing set() command
Use set() to set the CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to generate the import library.
Learn how interface library in CMake defines usage requirements for dependents without compiling or producing artifacts, guiding include directories, compile definitions, and link libraries for module five.
Create and test a header-only interface library by writing a main.cpp, call sum and diff, configure CMake to build an executable, and link the library with target_link_libraries.
Move the header-only library into its own space and call its cmake list from the root via a subdirectory, correcting the include path to header-only lib/include and building an executable.
Master cmake project structure by placing library and tests in separate folders, including a test folder, setting minimum version 3.30, and using add_subdirectory to build a header-only interface library.
What is planned for the next release with timeline
PUBLIC, PRIVATE, INTERFACE-Concepts
You answer this exercise, then watch the video.
Explore target scopes in a cmake demo by building a single library target A in a lib subdirectory, configured in root cmake and built to produce liba.a as static library.
Moving the header to a different location
Don't modify the `#include`, make changes in CMake.
Creation of library libB
Source Code to experiment.
Understand the components' relationship and decide the CMakeList accordingly
Implementation of libC.
Decision on the target scope to use.
Implement Usecase-2
Revisit Root CMake and make it more readable
Understand how CMake helps in managing dependencies.
Understand What happens when we use target_link_libraries() and target_include_derectories()
Explore how CMake handles target include directories and interface include directories, clarifying public versus private scopes and how consumers access headers during configure, generation, and build.
Explore how target link libraries and their private, public, and interface relationships affect linking, along with target include directories and get and set target properties in CMake.
Learn to inspect cmake target properties to diagnose build issues, and write user defined functions that print a target's properties, while understanding the difference between cmake functions and macros.
Review the plan for module five, detailing binary creation by integrating the static, dynamic, and interface libraries across modules two, three, and four, with a Visual Studio Code demonstration.
Demonstrate building a multi-module cmake project on linux using wsl, with module five and project one completed, using updated git sources and a cross-platform workflow from macos to linux.
Build succeeded, but the executable won’t work. To make it work, copy the DLL to the location of the exe.
Automate the creation of DLL and exe in the same directory.
Show how to configure and build a Linux project with CMake, clean the Linux build directory, reconfigure, rebuild, and verify the modify binary runs as expected.
Demo-Fix TestDynamicLib.exe Runtime Error in Windows.
Demo the project#1 code on a cross-platform.
Learn to set up GitHub Actions for cross-platform builds (macOS, Ubuntu, Windows) with CMake, resolve clang vs gcc issues, and validate multi-platform workflows.
optimize a cross-platform CMake workflow in GitHub Actions by removing explicit compilers, relying on the runner's default toolchain (gcc/clang/MSVC) across Ubuntu, Windows, and macOS, and maintain release builds.
Configure GitHub actions by disabling auto triggers, edit workflow lines, and implement a workflow dispatch with inputs to selectively build on Ubuntu, Windows, or Mac runners.
Use Case of Writing User-Defined Functions.
Explore defining a sum function in CMake to add two numbers using the math command, avoid string concatenation, and print accurate results with proper expression handling.
Discover how to replace multiple CMake commands with a single target executable, and learn to write reusable functions to simplify argument passing and library management.
Trace the build flow from preprocessor to compiler to assembler to linker to loader. Produce sample.i or sample.ii, sample.s, and sample.o from sample.c or sample.cpp, culminating in the executable.
Learn to solve the birthday chocolate subarray problem using a sliding window to count contiguous segments of length m with sum d.
Unlock the power of CMake with this comprehensive course designed for working professionals and engineering students. Begin with installing required tools on macOS, Windows, and Linux. Learn to build executables and libraries and grasp intermediate techniques in CMake. As you progress, expect regular updates introducing advanced topics like generator expressions, linking external libraries, writing Functions and macros, optimising CMake files, using CTest, CPack, VCPkg manager, Ninja generator, custom commands, and auto-generating config.cmake, writing own FindModule, dynamic library linking issues in Windows, automating build process for different pipelines and more. Gain practical knowledge through hands-on projects, including porting your existing Visual Studio legacy projects to modern CMake builds. Elevate your CMake expertise with us. Your journey to mastering CMake starts here! With each phase, you'll gain deeper insights and more control over your build environment, ensuring you can confidently handle any project. Join us and transform your CMake skills from foundational to advanced. Whether you're looking to enhance your career or excel in your studies, this course will provide you with the skills and knowledge you need to succeed. Get ready to take your CMake proficiency to the next level with step-by-step guidance, real-world applications, and expert instruction designed to make you a CMake master."