An open API service indexing awesome lists of open source software.

https://github.com/agentcooper/cpp-makefile-example

Example Makefile for a C++ project with incremental compilation and automatic resolution of dependencies (header files)
https://github.com/agentcooper/cpp-makefile-example

cpp makefile

Last synced: 8 days ago
JSON representation

Example Makefile for a C++ project with incremental compilation and automatic resolution of dependencies (header files)

Awesome Lists containing this project

README

          

Example Makefile for a C++ project with incremental compilation and automatic resolution of dependencies (header files).

## Demo

Initial compilation:

```bash
% make
g++ -Wall -std=c++20 -MMD -c src/A.cpp -o build/A.o
g++ -Wall -std=c++20 -MMD -c src/B.cpp -o build/B.o
g++ -Wall -std=c++20 -MMD -c src/main.cpp -o build/main.o
g++ -Wall -std=c++20 -MMD -o main build/A.o build/B.o build/main.o
```

Edit header dependency:

```bash
sed -i '' 's/John/Jane/' src/C.hpp
```

Only B module is rebuilt on recompilation:

```bash
% make
g++ -Wall -std=c++20 -MMD -c src/B.cpp -o build/B.o
g++ -Wall -std=c++20 -MMD -o main build/A.o build/B.o build/main.o
```