SE 3800, Note 2c
Makefiles

Makefile Review

Simplifying Makefiles

A shorter file (untested!)


# makefile for cube code

CPPFLAGS=-std=c++14 -Wall --coverage

all: cube cube_test

cube.o: cube.h cube.cpp

cube_test.o: cube.h cube_test.cpp

main.o: cube.h main.cpp

cube: cube.o main.o

cube_test: cube.o cube_test.o
	g++ -pthread $(CPPFLAGS) cube.o cube_test.o -lgtest_main -lgtest -lpthread -o cube_test

coverage: cube_test
	mkdir -p code_coverage_report
	./cube_test
	lcov --directory ./ --capture --output-file ./code_coverage.info -rc lcov_branch_coverage=1
	genhtml code_coverage.info --branch-coverage --output-directory ./code_coverage_report/

clean:
	rm -f *.o *.gcda *.gcno code_coverage.info cube cube_test 
        rm -rf code_coverage_report

Alternative Build Environments