Skip to content

Instantly share code, notes, and snippets.

@Leandros
Last active January 8, 2022 23:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leandros/3a4bb52e2df399903fe9b244650d9547 to your computer and use it in GitHub Desktop.
Save Leandros/3a4bb52e2df399903fe9b244650d9547 to your computer and use it in GitHub Desktop.
Minimal C++ Makefile
CC = clang++
CXX = clang++
DEBUG = -ggdb -O1 -march=native
RELEASE = -O2
CPPFLAGS := -I.
CXXFLAGS := $(DEBUG) -W -Wall -Wextra -std=c++17
LDLIBS := -lm
OUTPUT_OPTION = -MMD -MP -o $@ -MJ $@.json
# Modify your C++ filesuffix here:
SRC := $(wildcard *.cpp)
OBJ := $(SRC:.cpp=.o)
DEP := $(SRC:.cpp=.d)
.PHONY: compile_commands clean
# You add new targets here:
all: test
# Add your objects here.
# Make sure one object has the same name as the target!
test: test.o dialog.o button.o
compile_commands: test
gsed -e '1s/^/[\n/' -e '$$s/,$$/\n]/' *.o.json > compile_commands.json
clean:
-rm -f $(OBJ) $(DEP) test
-include $(DEP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment