
Master CMake from fundamentals to expert practices by building real projects and applying generator expressions. Learn Findpackage, external dependencies, cpack, ctest, and cross-platform workflows across Windows, Linux, and Mac.
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 fundamentals, from installation and purpose to cmakelists.txt, and set up environments for Windows, Linux, and Mac, while using GitHub to manage cross-platform C/C++ sources.
Install essential tools for CMake mastery: set up CMake 3.25 or 3.30, optionally Ninja, VS code, Visual Studio 2022 (Windows), Git, and WSL (optional) for Windows, Linux, and Mac.
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.
Write a CMakeLists.txt with cmake_minimum_required(VERSION 3.6) and optional 3.25 version handling that auto selects the latest 3.25.x, define a project, and use the message command to print output.
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.
Learn how to configure and generate build pipelines with CMake by creating and navigating build directories, locating the source CMakeLists.txt, and exploring the generator concept.
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.
Explore the folder structure for cmake mastery, covering include, src, and test directories across modules one to five, and learn to build, link, and test static, dynamic, and interface libraries.
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.
Configure differently by using cmake dot to locate the cmake lists in the current directory, and specify root paths for source and build to use a static library.
Explore target include directories and header file placement as you troubleshoot build errors, adjust include paths, validate with Visual Studio IntelliSense, and learn when to generate a dynamic 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.
Demonstrate generating a Windows static library with CMake, building in a build directory, and linking to an executable using target include directories and .lib.
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.
Explore exporting symbols in CMakeLists.txt during CMake configure on Windows, verify the export library build, and compare static and dynamic libraries while understanding set vs command-line behavior.
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 a header-only interface library named header-only library, exposing inline functions sum and df using 32-bit types, with a CMake configuration that sets include directories.
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.
Create a main.cpp that uses library a and configure CMake to link it. Learn how public, interface, and private scopes control include directories and header visibility for the consumer.
Moving the header to a different location
Don't modify the `#include`, make changes in CMake.
Create library B in CMake, expose its header with a target include directory, and link it in main.cpp; then explore using library A through library B while debugging build configurations.
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.
Explore building module five by integrating module two, module three, and module four libraries with CMake 3.30, managing include paths, static/dynamic/header-only libraries, and disambiguating functions via namespaces.
Configure and use module three as a dynamic library by placing code in mod three namespace inside module three.h and calling it from main.cpp, with cmake builds and linker fixes.
Learn to manage module headers and include directories in cmake, using interface and private paths, and link static, dynamic, and header-only libraries across Unix-like and Windows environments.
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.
Learn to export only selected functions in a Windows DLL using dllexport, prevent exporting internal symbols, and configure cmake to build and link with the import library.
fix cross-platform dll export issues by using windows-specific declspec when building on windows, and define functions without dll export on linux and macos, then verify cross-platform builds with cmake.
Demo the project#1 code on a cross-platform.
Learn to set up a GitHub action workflow to build a CMake-based multi-platform project, configure and build across Ubuntu, Windows, and Mac OS using a YAML workflow.
Coordinate cross-platform builds and runs of executables in a GitHub Actions workflow, debugging parsing errors, and aligning build directories across Windows, Mac, and Linux.
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.
Master GitHub Actions by configuring push and pull request triggers on the main branch, exploring workflow dispatch for manual runs, and managing multiple workflow files and hosted runners.
Edit and commit changes to workflows, compare auto and manual triggers, and manage branches, tags, and workflow dispatch triggers for a final release.
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.
Explore a function with six arguments, argv, and v2 calls, printing and incrementing a count, listing elements one through six while preparing to parse function arguments in a robust way.
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."