Skip to content

Instantly share code, notes, and snippets.

@sbillig sbillig/Makefile
Created Jan 28, 2014

Embed
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 := $(TESTSRCS:.cpp=.o)
TESTOBJS += $(filter-out src/main.o,$(OBJS))
TARGET := thing
all: $(TARGET)
$(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET)
test: $(TESTOBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TESTOBJS) -o run_tests
./run_tests
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
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.