From c29f7cb2331131e1af0d7d27d5ce50786058c39f Mon Sep 17 00:00:00 2001 From: PrzemekB Date: Mon, 21 Jan 2019 01:14:10 +0100 Subject: [PATCH 1/2] hpp files moved to inc,Makefile added --- CMakeLists.txt | 2 ++ Makefile | 13 +++++++++++++ Circle.hpp => inc/Circle.hpp | 0 Rectangle.hpp => inc/Rectangle.hpp | 0 Shape.hpp => inc/Shape.hpp | 0 Square.hpp => inc/Square.hpp | 0 6 files changed, 15 insertions(+) create mode 100644 Makefile rename Circle.hpp => inc/Circle.hpp (100%) rename Rectangle.hpp => inc/Rectangle.hpp (100%) rename Shape.hpp => inc/Shape.hpp (100%) rename Square.hpp => inc/Square.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 395f342..08d2e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,4 +4,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) project(modern_cpp) cmake_minimum_required(VERSION 2.8) aux_source_directory(. SRC_LIST) +include_directories(inc) +add_definitions(-Wall -Wextra -Werror) add_executable(${PROJECT_NAME} ${SRC_LIST}) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..56ae508 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +#target which is not a file +.PHONY: all +all: debug release + +debug: *.cpp inc/*.hpp + g++ *.cpp -std=c++17 -Wall -Wextra -Werror -g -o debug -Iinc + +release: *.cpp inc/*.hpp + g++ *.cpp -std=c++17 -Wall -Wextra -Werror -O3 -o release -Iinc + +.PHONY: clean +clean: + rm debug release diff --git a/Circle.hpp b/inc/Circle.hpp similarity index 100% rename from Circle.hpp rename to inc/Circle.hpp diff --git a/Rectangle.hpp b/inc/Rectangle.hpp similarity index 100% rename from Rectangle.hpp rename to inc/Rectangle.hpp diff --git a/Shape.hpp b/inc/Shape.hpp similarity index 100% rename from Shape.hpp rename to inc/Shape.hpp diff --git a/Square.hpp b/inc/Square.hpp similarity index 100% rename from Square.hpp rename to inc/Square.hpp From 83f996a63af9bf4ee40846e5364823d729896f65 Mon Sep 17 00:00:00 2001 From: PrzemekB Date: Mon, 21 Jan 2019 02:32:55 +0100 Subject: [PATCH 2/2] Makefile - homework --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 56ae508..41a6fd1 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,21 @@ -#target which is not a file +#phony is used to specify that target is not a file +#(to avoid conflicts when there are files named clean or all) + +CXX = g++ +CXXFLAGS = -std=c++17 -Wall -Wextra -Werror +HEADERSFLAG = -Iinc + +SRCS = *.cpp +INCS = inc/*.hpp + .PHONY: all all: debug release -debug: *.cpp inc/*.hpp - g++ *.cpp -std=c++17 -Wall -Wextra -Werror -g -o debug -Iinc +debug: $(SRCS) $(INCS) + $(CXX) $(CXXFLAGS) $(HEADERSFLAG) -g -o $@ $(SRCS) -release: *.cpp inc/*.hpp - g++ *.cpp -std=c++17 -Wall -Wextra -Werror -O3 -o release -Iinc +release: $(SRCS) $(INCS) + $(CXX) $(CXXFLAGS) $(HEADERSFLAG) -O3 -o $@ $(SRCS) .PHONY: clean clean: