Welcome to the CMake Mastery Learning Path! This is a systematic learning system designed to help you grow from a beginner to a CMake expert.
中文版本 | English Version
This project provides a complete CMake learning system, including:
- Progressive Learning Modules: From basics to advanced, step by step
- Practical Projects: Consolidate knowledge through real-world projects
- Reference Materials: Cheatsheets, best practices, and troubleshooting guides
- Progress Tracking: Clear learning path and milestones
Learn basic CMake concepts, syntax, and simple project configuration.
Topics: CMake introduction, first project, basic commands (project, add_executable, add_library)
Estimated Time: 2-3 weeks
Master variables, control flow, functions, and external library integration.
Topics: Variables, conditionals, functions/macros, find_package, generator expressions
Estimated Time: 3-4 weeks
Learn modern CMake best practices and advanced features.
Topics: Modern CMake, custom commands, install/export, package config, toolchains, CTest
Estimated Time: 4-5 weeks
Apply your knowledge through comprehensive projects.
Projects: C++ library project, cross-platform application, complex dependency management
Estimated Time: 3-4 weeks
Quick reference resources for daily work.
Content: Command cheatsheet, best practices, common errors, code templates
-
CMake: Version 3.15 or higher
- Download CMake
- Verify installation:
cmake --version
-
C++ Compiler: Any of the following
- Windows: Visual Studio 2017+ or MinGW
- Linux: GCC 7+ or Clang 6+
- macOS: Xcode Command Line Tools
-
Build Tools:
- Windows: Visual Studio or Ninja
- Linux/macOS: Make or Ninja
- Git: For version control and getting example code
- Text Editor/IDE: VS Code, CLion, Visual Studio, etc.
- Basic C/C++ programming knowledge
- Command line basics
- Understanding of compilation and linking concepts
# Check CMake version
cmake --version
# Check compiler
# Windows (MSVC)
cl
# Linux/macOS (GCC)
gcc --version
# Linux/macOS (Clang)
clang --version- Read Learning Path: Check LEARNING_PATH.md for the complete roadmap
- Start with Basics: Enter 01-basics directory to begin the first module
- Follow Tutorials: Read tutorial documents in order
- Run Examples: Build and run example code
- Complete Exercises: Consolidate knowledge through exercises
- Track Progress: Check off completed items in LEARNING_PATH.md
# Enter example directory
cd 01-basics/examples/hello-world
# Create build directory
mkdir build
cd build
# Configure project
cmake ..
# Build project
cmake --build .
# Run program
# Windows
.\Debug\hello.exe
# Linux/macOS
./hello- Progressive Learning: Follow modules in order, don't skip basics
- Hands-On Practice: Run example code for every tutorial
- Complete Exercises: Exercises are key to consolidating knowledge
- Take Notes: Record important concepts and common pitfalls
- Reference Documentation: Consult 05-reference directory when encountering issues
- Weekly Investment: Recommended 5-10 hours per week
- Total Time: Complete learning path takes approximately 12-16 weeks
- Flexible Adjustment: Adjust learning pace based on your background and available time
- Common Issues: See 05-reference/common-errors.md
- Best Practices: Refer to 05-reference/best-practices.md
- External Resources: Check 05-reference/resources.md
cmake-mastery-learning-path/
├── README.md # This file (English)
├── CONTRIBUTING.md # Contribution guidelines (English)
├── CHANGELOG.md # Change log (English)
├── LEARNING_PATH.md # Learning path and progress tracking
├── docs/
│ ├── zh-CN/ # Chinese documentation
│ │ ├── README.md # Project README (Chinese)
│ │ ├── CONTRIBUTING.md # Contribution guide (Chinese)
│ │ └── CHANGELOG.md # Change log (Chinese)
│ ├── performance-optimization.md # Performance optimization guide
│ └── project-organization.md # Project organization guide
├── 01-basics/ # Basics module
│ ├── README.md # Module overview
│ ├── tutorials/ # Tutorial documents
│ ├── examples/ # Runnable example code
│ └── exercises/ # Exercise projects (with starter and solution)
├── 02-intermediate/ # Intermediate module
│ ├── README.md
│ ├── tutorials/
│ ├── examples/
│ └── exercises/
├── 03-advanced/ # Advanced module
│ ├── README.md
│ ├── tutorials/
│ ├── examples/
│ └── exercises/
├── 04-projects/ # Real-world projects module
│ ├── project-01-cpp-library/ # C++ library project
│ ├── project-02-cross-platform-app/ # Cross-platform application
│ └── project-03-complex-deps/ # Complex dependencies project
├── 05-reference/ # Reference materials
│ ├── cheatsheet.md # Command cheatsheet
│ ├── best-practices.md # Best practices
│ ├── common-errors.md # Common errors
│ ├── resources.md # External resources
│ └── templates/ # Code templates
├── docs/ # Additional documentation
│ ├── zh-CN/ # Chinese documentation
│ │ ├── README.md # Project README (Chinese)
│ │ ├── CONTRIBUTING.md # Contribution guide (Chinese)
│ │ └── CHANGELOG.md # Change log (Chinese)
│ ├── project-organization.md # Project organization guide
│ └── performance-optimization.md # Performance optimization guide
└── tests/ # Testing framework
Tutorials:
- 01-what-is-cmake.md - CMake introduction
- 02-first-project.md - Create first project
- 03-basic-commands.md - Basic commands
Examples:
- hello-world - Simplest executable
- simple-library - Create and use static library
- linking-libraries - Link multiple libraries
Exercises:
- exercise-01 - Create simple executable project
- exercise-02 - Create and use static library
- exercise-03 - Multi-source file project
Tutorials:
- 01-variables.md - Variables and cache
- 02-control-flow.md - Control flow
- 03-functions-macros.md - Functions and macros
- 04-find-package.md - Find external libraries
- 05-generator-expressions.md - Generator expressions
Examples:
- multi-directory - Multi-directory project
- external-libraries - External library integration
- conditional-build - Conditional compilation
Exercises: 5 exercise projects covering variables, conditional compilation, multi-directory structures, etc.
Tutorials:
- 01-modern-cmake.md - Modern CMake
- 02-custom-commands.md - Custom commands
- 03-install-export.md - Install and export
- 04-package-config.md - Package configuration
- 05-toolchains.md - Toolchains and cross-compilation
- 06-testing-ctest.md - CTest integration
Examples:
- modern-library - Modern CMake library
- package-config - Installable package
- cross-compile - Cross-compilation
- testing-integration - Test integration
- fetch-content - FetchContent usage
Exercises: 5 advanced exercise projects
- project-01-cpp-library - Complete C++ library project
- project-02-cross-platform-app - Cross-platform application
- project-03-complex-deps - Complex dependency management
- cheatsheet.md - CMake command cheatsheet
- best-practices.md - Modern CMake best practices
- common-errors.md - Common errors and solutions
- resources.md - Recommended external resources
- templates/ - Project templates (library, executable, package)
- project-organization.md - Project organization best practices
- performance-optimization.md - Build performance optimization
Q: How long does it take to complete the entire learning path?
A: The complete learning path takes approximately 12-16 weeks, with 5-10 hours per week. The actual time depends on your background and learning pace.
Q: Can I skip certain modules?
A: It's not recommended to skip the basics module. If you already have some CMake experience, you can quickly review the basic content, but it's recommended to at least complete the exercises to ensure understanding.
Q: Which CMake version should I use?
A: CMake 3.15 or higher is recommended. The examples and tutorials in this project are based on modern CMake practices and require newer version support.
Q: Do I need to know C++?
A: Yes, basic C/C++ programming knowledge is required. CMake is a build system primarily used for C/C++ projects.
Q: CMake configuration fails with "compiler not found" error?
A: Ensure a C++ compiler is installed and added to system PATH. Windows users may need to run CMake in Visual Studio Developer Command Prompt.
Q: How to use MinGW instead of MSVC on Windows?
A: Use the -G "MinGW Makefiles" option:
cmake -G "MinGW Makefiles" ..Q: What if example build fails?
A:
- Check if CMake version meets requirements
- Review error messages, refer to common-errors.md
- Ensure all dependencies are installed
- Try cleaning build directory and rebuilding
Q: How to switch between different build types (Debug/Release)?
A: Use the -DCMAKE_BUILD_TYPE option:
# Debug build
cmake -DCMAKE_BUILD_TYPE=Debug ..
# Release build
cmake -DCMAKE_BUILD_TYPE=Release ..Q: Exercise starter code is incomplete?
A: This is intentional! The purpose of exercises is for you to complete the missing parts. If you encounter difficulties, you can check the reference answer and EXPLANATION.md in the solution directory.
Q: Should I read tutorials or examples first?
A: It's recommended to read tutorials first to understand concepts, then run example code, and finally complete exercises. This helps consolidate knowledge better.
Q: I've completed all exercises, what's next?
A:
- Complete real-world projects in 04-projects
- Try applying CMake to your own projects
- Read advanced topics in docs directory
- Refer to best practices in 05-reference to optimize existing projects
Q: How to track my learning progress?
A: Use the LEARNING_PATH.md file to check off completed tutorials, examples, and exercises.
We welcome and appreciate all forms of contributions!
-
Report Issues
- Found errors or unclear instructions
- Example code doesn't run
- Spelling or grammar errors in documentation
-
Improve Content
- Enhance tutorial explanations
- Add more examples
- Improve exercise projects
- Update outdated information
-
Add New Content
- New example projects
- Additional exercises
- Supplementary documentation
- Best practice cases
-
Share Experience
- Learning insights
- Practical tips
- Common problem solutions
- Fork this repository
- Create feature branch (
git checkout -b feature/your-feature) - Commit changes (
git commit -m 'Add some feature') - Push to branch (
git push origin feature/your-feature) - Create Pull Request
For detailed contribution guidelines, see CONTRIBUTING.md.
- CMake Code: Follow modern CMake best practices (refer to 05-reference/best-practices.md)
- Documentation: Use clear, concise language with consistent formatting
- Examples: Ensure all examples build successfully and include detailed README
- Exercises: Provide clear task descriptions and complete solutions
Before submitting Pull Request, ensure:
- All new examples build successfully
- Exercise solution code is tested
- Documentation links are correct
- Run test suite (if applicable)
# Run tests
cd tests
pytest -vThis project is licensed under the MIT License. See LICENSE file for details.
Thanks to all developers and educators who contribute to the CMake community, especially:
- CMake official team
- All developers contributing examples and documentation
- Learners providing feedback and suggestions
- Issue Reporting: Via GitHub Issues
- Discussion: Via GitHub Discussions
- Documentation Issues: See common-errors.md
Ready? Let's start your CMake mastery journey from LEARNING_PATH.md!
🚀 Quick Links:
- Learning Path - Start learning
- Basics Module - First module
- Command Cheatsheet - Quick reference
- Common Issues - Troubleshooting
- Contributing Guide - How to contribute
- Changelog - Version history
- Current Version: 1.0.0
- Release Date: 2026-01-29
- CMake Version: 3.15+
- Status: Stable
- 中文文档: docs/zh-CN/
For version history and updates, see CHANGELOG.md.