Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

Back to your source shelf

Inside the companion

Build your studio

Two small CMake checkpoints: one executable, then a library with tests and presets.

Project files 9

Start from an empty folder

Author the two checkpoints, observe failures, and build with CMake, Ninja, and Clang.

55 lines README.md
# CMake from an empty folder

The lesson at `/workshop/build-studio` teaches you to author this project, one file
at a time. These snapshots are checkpoints, not prerequisites to copy blindly.

1. Make an empty `my-checker/` folder. Type `01-one-file/main.cpp` and
   `01-one-file/CMakeLists.txt` there.
2. In that folder configure, build, and run:

```sh
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug
cmake --build build --verbose
./build/first-target
```

Expected: `One source. One target.`

3. Create `include/studio/checker.hpp`, `src/checker.cpp`, `src/main.cpp`, and
   `tests/checker_tests.cpp` following the chapter. Replace the root CMake file
   with the stage-2 target graph, then append its CTest block.
4. Configure and run checks:

```sh
cmake -S . -B build -DBUILD_TESTING=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure --no-tests=error
./build/checker
```

Expected: one passing test, `8 checker contracts passed` with verbose CTest,
and `checker: 32 224 32`. Added learner tests increase the count.

5. In your practice copy, temporarily list `src/main.cpp` instead of
   `src/checker.cpp` as checker_core's source. Observe the undefined
   `studio::shade` link failure. Restore the source list and verify.
6. Change one expected value in the table. Build, observe the CTest failure,
   restore, build, and verify again. Never leave an intentional fault in the
   reference snapshot.
7. Create the complete stage-2 `CMakePresets.json`; run:

```sh
cmake --preset debug
cmake --build --preset debug
ctest --preset debug
./build/debug/checker
cmake --preset release
cmake --build --preset release
ctest --preset release
./build/release/checker
```

These commands assume Clang, Ninja, and CMake 3.25+ are available. Both programs
print the same checker intensities. The lesson links versioned official CMake
documentation. No downloading or installation occurs during configuration.

This is the file included with the course. Copy and download give you its complete source.

Taking your work offline? Download all course companions