Overview of CMake Project Build Process

One-Click Three ConnectionsContinuous Valuable Content!

Overview of CMake Project Build Process

Introduction

Guite Embedded focuses on sharing knowledge about embedded software and hardware.

1

First Build

– First, execute CMake in the project root directory to generate the Makefile or other build tool files required for the build system. This is typically done by running a command like `cmake /path/to/source`.

– Then, execute the `make` command to compile the project and generate the executable.

2

Subsequent Modifications to Source Files

– If you modify the source files, you usually only need to run the `make` command again. Make will detect changes in the source files and recompile the necessary parts without needing to rerun CMake.

3

When to Rerun CMake

– If you have modified the CMake configuration file for the project (such as CMakeLists.txt), or added/removed source files, then you need to rerun CMake to update the build system configuration.

– In this case, you need to first clear the previous build directory (you can delete the build directory), then rerun `cmake /path/to/source`, and finally execute `make`.

In summary, if you only modify the source files without changing the CMake configuration file, you typically only need to run `make` to recompile the project. You only need to rerun CMake when you modify the CMake configuration file or the project structure.
Overview of CMake Project Build Process
Overview of CMake Project Build Process

Share This

Overview of CMake Project Build Process

Like This

Overview of CMake Project Build Process

Watching This

Leave a Comment