Stage 6 · Lesson 2 of 7
CMake builds
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 repoFreeProject Based Learning
Community maintained · Beginner
Follow one guided build in your language, then build your own without a guide
Keep handy
Also worth your time
How to present each project: the problem, stack, challenges and results
- Build Your Own XGo deeper
When you want a harder build: a shell, a key-value store or a tiny Git, from scratch