feat(cmat): add cmake build for course material
Add a CMakeLists.txt to each exercise directory, included from cmat/CMakeLists.txt, so every exercise and solution becomes a buildable target. GUI exercises link the curses-based DOS_Unix implementations on Unix-like systems; the Windows-specific DOS variants are not compiled. Exercises without a portable path or with missing dependencies (Boost) are reported as not available at configure time. Targets are excluded from the default build and built by name, e.g. `cmake --build build --target Ex11`, so intentionally buggy exercises such as Ex21 do not break the default build. Also fix two portability issues: rename Ex11bug/pole.h to Pole.h for case-sensitive filesystems and drop the extra Light:: qualification in SolutionEx71A/Light.h. Document build commands and layout in AGENTS.md. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
@@ -10,8 +10,22 @@ is added, document its layout under "Source Layout".
|
||||
|
||||
## Build System
|
||||
|
||||
No build system is set up yet. When one is added for the course examples,
|
||||
document its configure, build, and test commands here.
|
||||
CMake (3.21+) with Ninja.
|
||||
|
||||
```sh
|
||||
cmake -B build -G Ninja
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
Course exercises in `cmat/` are excluded from the default build; build one by
|
||||
target name, e.g.:
|
||||
|
||||
```sh
|
||||
cmake --build build --target Ex11
|
||||
```
|
||||
|
||||
Tests (optional): configure with `-DBUILD_TESTING=ON`, then run `ninja check` in
|
||||
the build directory.
|
||||
|
||||
## Coding Conventions
|
||||
|
||||
@@ -33,23 +47,23 @@ document its configure, build, and test commands here.
|
||||
- **Naming:** `SCREAMING_SNAKE_CASE` only for macros and constants
|
||||
- **Header extensions:** C++ headers use `.hpp`, C headers use `.h`
|
||||
- Include order:
|
||||
1. C++ standard library headers (`<chrono>`, `<vector>`, etc.)
|
||||
2. _(blank line)_
|
||||
3. C standard library headers (`<stdlib.h>`, `<string.h>`, etc.)
|
||||
4. _(blank line)_
|
||||
5. OS-specific headers (Windows API, POSIX, etc.)
|
||||
6. _(blank line)_
|
||||
7. Third-party dependencies (`"fmt/core.h"`, etc.)
|
||||
8. _(blank line)_
|
||||
9. Local/project headers
|
||||
1. C++ standard library headers (`<chrono>`, `<vector>`, etc.)
|
||||
2. _(blank line)_
|
||||
3. C standard library headers (`<stdlib.h>`, `<string.h>`, etc.)
|
||||
4. _(blank line)_
|
||||
5. OS-specific headers (Windows API, POSIX, etc.)
|
||||
6. _(blank line)_
|
||||
7. Third-party dependencies (`"fmt/core.h"`, etc.)
|
||||
8. _(blank line)_
|
||||
9. Local/project headers
|
||||
|
||||
## Shell Scripts
|
||||
|
||||
- Always use `#!/bin/sh` shebang for shell scripts
|
||||
- Scripts must be POSIX compliant (no bashisms)
|
||||
- When providing commands to users:
|
||||
- Windows/PowerShell: use `` ` `` for line continuation
|
||||
- Unix/Linux/macOS: use `\` for line continuation
|
||||
- Windows/PowerShell: use `` ` `` for line continuation
|
||||
- Unix/Linux/macOS: use `\` for line continuation
|
||||
|
||||
## Commit Messages
|
||||
|
||||
@@ -84,7 +98,7 @@ releases of the course material.
|
||||
|
||||
- All markdown files are formatted with **oxfmt**
|
||||
- **Always run `npx oxfmt --write .` after editing any markdown file**
|
||||
- This is mandatory. Do not skip it. Run it before finishing your response
|
||||
- This is mandatory. Do not skip it. Run it before finishing your response
|
||||
- Use `npx oxfmt --check .` to verify formatting before committing
|
||||
- Config is in `.oxfmtrc.json` at the project root
|
||||
- Do not manually fight the formatter. Let oxfmt handle spacing, line breaks,
|
||||
@@ -98,10 +112,25 @@ cppcourse/
|
||||
README.md # Project docs
|
||||
.oxfmtrc.json # oxfmt config
|
||||
.agents/ # Agent skills (git workflow)
|
||||
CMakeLists.txt # Build system entry point
|
||||
deps/ # CMake helper modules (platform, flags, Find* deps)
|
||||
cmat/ # Course material: exercises and solutions
|
||||
397/ # Original copy of the course material (reference only)
|
||||
```
|
||||
|
||||
Course content (lectures, exercises, examples) will be added as the course is
|
||||
developed. Document the layout here when it takes shape.
|
||||
`cmat/` layout:
|
||||
|
||||
- `Ex*/`: exercise starting points. Some intentionally contain bugs that
|
||||
students fix during the course; their targets fail to compile (or misbehave at
|
||||
runtime) until fixed.
|
||||
- `SolutionEx*/`: working solutions of the exercises.
|
||||
- `DOS_Unix/`: platform Keyboard/Screen implementations shared by the GUI
|
||||
exercises. The DOS variants are Windows-specific; on Unix-like systems the
|
||||
curses variants are built instead (linked as the `dos_unix` library).
|
||||
- Each exercise directory holds a `CMakeLists.txt` that defines its target via
|
||||
`cmat_add_exercise()` (see `cmat/CMakeLists.txt`). Exercises that need a
|
||||
missing dependency (e.g. Boost) are reported as not available at configure
|
||||
time and skipped.
|
||||
|
||||
## Behavioral Guidelines
|
||||
|
||||
|
||||
Reference in New Issue
Block a user