Skip to content

Instantly share code, notes, and snippets.

@sbillig sbillig/Makefile
Created Jan 28, 2014

What would you like to do?
C++ starter Makefile
CXX := clang++
CXXFLAGS := -isystem ./external -std=c++11 -stdlib=libc++ -MMD -MP \
-Wall -Wpedantic -Wextra -Weffc++ -O3
SRCS := $(wildcard src/*.cpp)
OBJS := $(SRCS:.cpp=.o)
TESTSRCS := $(wildcard tests/*.cpp)
TESTOBJS += $(filter-out src/main.o,$(OBJS))
TARGET := thing
all: $(TARGET)
test: $(TESTOBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TESTOBJS) -o run_tests
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
rm -f $(OBJS) $(TARGET) $(TESTOBJS) run_tests
-include $(OBS:.o=.d)
-include $(TESTOBJS:.o=.d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.