Programming foundations

Stage 6 · Lesson 2 of 7

CMake builds

Build and ship your first projects

Once a project has several files and a test library, typing g++ commands by hand stops working well. is a build system: it describes the build in CMakeLists.txt and generates the real build files for each platform. For example, add_executable(ledger src/main.cpp src/ledger.cpp) defines the program and set(CMAKE_CXX_STANDARD 20) picks the C++ standard.

target_compile_options sets , such as turning warnings on. Build out of source, in a separate folder: cmake -S . -B build, then cmake --build build. Add build/ to .gitignore.

Put the core logic in a library target with add_library, so both the program and the tests link against it. can download a such as when you configure. Most IDEs open a CMake project directly.

A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with

  • GitHub repoFree
    Project Based Learning

    Community maintained · Beginner

    Follow one guided build in your language, then build your own without a guide

Keep handy

  • Free APIs that give a small project real data to work with

Also worth your time

Mark this stage as not done?