Generic Makefile for C++ project build

PHOTO EMBED

Wed Feb 21 2024 16:09:03 GMT+0000 (Coordinated Universal Time)

Saved by @papi292 #c++ #makefile #make

# Makefile

SRC := $(wildcard *.cpp) $(wildcard *.cc) $(wildcard *.c)
OBJ := $(SRC:.cpp=.o) $(SRC:.cc=.o) $(SRC:.c=.o)
TARGET := my_program

CXX := /opt/homebrew/opt/ccache/libexec/g++
CXXFLAGS := -fdiagnostics-color=always -g -Wall -std=c++20

$(TARGET): $(OBJ)
    $(CXX) $(CXXFLAGS) -o $@ $^

clean:
    rm -f $(OBJ) $(TARGET)
content_copyCOPY

builds project for C++ using "g++" compiler (my MacBook Pro) needs tweaks for other OS