Skip to content

Instantly share code, notes, and snippets.

Last active Jun 23, 2020
What would you like to do?
Minimal C++ Makefile
CC = clang++
CXX = clang++
DEBUG = -ggdb -O1 -march=native
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
-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