# Introduction to CMake
###### tags: `tutorial` `electrical_system` `NTURT` `software`
##### Author: @QuantumSpawner
## Why using cmake
Unlike modern languages such as `python` or `go` that has built-in package manager for external libraries, for C/C++, everything is down to the user to tell the compiler where the header files and the library binaries are when compiling. (Checkout: [Important GCC Flags in Linux](https://linuxhandbook.com/gcc-flags/) to see how this is done by compiler flags.) Hence there comes `make` to simplify this step. (Checkout: [Makefile Tutorial](https://makefiletutorial.com/) for how this is done by writting a `makefile`.) However, `make` is still to some extent unintuitive since you're essentially writting compiler flags and lack of support for basic functionality such as conditions, functions, etc. Hence `cmake` is invented to automate the process of creating `makefile` to be `make`d according to its own `CMakeLists.txt` config file.
As most C/C++ projects nowadays adopt `cmake`, ROS2 also relys on it to build and even created its own tool `ament` to augment its ability. You may also find extensive use of `cmake` when you go through ROS2 tutorials. Hence it's somewhat necessary for you to learn how to use it.
## Using cmake
Official cmake tutorial: [CMake Tutorial](https://cmake.org/cmake/help/v3.17/guide/tutorial/index.html)
CMake documentation: [CMake Reference Documentation](https://cmake.org/cmake/help/latest/)
CMake documentation for using in ROS2: [ament_cmake user documentation](https://docs.ros.org/en/humble/How-To-Guides/Ament-CMake-Documentation.html)
:::info
Note: There is a cmake plugin in vs code that can help you configure and build your code.
:::
:::info
Note: There is no designated homework for cmake as you're already using it when doing other homeworks in ROS2.
:::