CMake:
A cross-platform build system generator.
It is a build system generator, not a compiler.
Main Function: To generate build files suitable for different platforms and toolchains based on your project configuration (<span>CMakeLists.txt</span>).
CMakeLists.txt:
A configuration file.
Ninja:
It is a build system executor.
Main Function: To read build rule files (such as <span>build.ninja</span>), and then call the compiler and linker to generate executables or libraries.
Features:
-
Very lightweight and starts quickly;
-
Focuses on incremental builds (only compiles changed files);
-
Does not handle project management, IDE, code editing, etc.;
-
Ninja is a build tool;
What system does Ninja execute builds for?
It reads build rule files (such as <span>build.ninja</span>);
Calls the compiler and linker according to the rules;
Generates executables (.exe), static libraries (.a/.lib), dynamic libraries (.dll/.so), and other products.
MinGW:
It is a compiler;
It can compile C and C++ code;
The generated executables are native Windows programs.
4️⃣ Process Summary Diagram (Text Version)
CMakeLists.txt
↓
CMake
↓
build.ninja (rule file)
↓
Ninja (executor)
↓
MinGW/G++ (compiler)
↓
main.o → CLionProjects.exe
💡 Key Understanding:
-
Ninja ≠ Compiler
-
MinGW ≠ Build System
-
Ninja calls MinGW to complete the compilation
-
Ninja is the “conductor”, MinGW is the “worker”.