Created
September 30, 2023 13:59
-
-
Save honi/18761505bd12e3e16ea67b9c22a317b5 to your computer and use it in GitHub Desktop.
Makefile to compile cpp files in src/ as individual programs in bin/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXX := g++ | |
CXX_FLAGS := -pthread --std=c++2a | |
VPATH := bin/ | |
SRCS := $(shell find src -name '*.cpp') | |
BINS := $(patsubst src/%.cpp,%,$(SRCS)) | |
RUNS := $(addprefix run-,$(BINS)) | |
all: $(BINS) | |
$(BINS): %: src/%.cpp | |
@mkdir -p bin | |
$(CXX) $(CXX_FLAGS) $< -o bin/$@ | |
$(RUNS): run-%: % | |
./bin/$* | |
clean: | |
rm -rf bin | |
.PHONY: all clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment