Created
September 15, 2016 13:38
-
-
Save eanil/2c91e6cc684a69ff3202e8cf6f0f46bf to your computer and use it in GitHub Desktop.
Simple c++ project structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# after http://hiltmon.com/blog/2013/07/03/a-simple-c-plus-plus-project-structure/ | |
# | |
# TODO: | |
# | |
CC := g++ # This is the main compiler | |
# CC := clang --analyze # and comment out the linker last line for sanity | |
SRCDIR := src | |
BUILDDIR := build | |
TARGET := bin/runner | |
SRCEXT := cpp | |
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) | |
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) | |
CFLAGS := -g # -Wall | |
LIB := -pthread -L lib -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt | |
INC := -I include | |
$(TARGET): $(OBJECTS) | |
@echo " Linking..." | |
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) | |
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) | |
@mkdir -p $(BUILDDIR) | |
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< | |
clean: | |
@echo " Cleaning..."; | |
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) | |
# Tests | |
tester: | |
$(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester | |
# Spikes | |
ticket: | |
$(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket | |
.PHONY: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment