From 9e3f68e7f08a743c9f8289fb3ccbda00cca22b1d Mon Sep 17 00:00:00 2001 From: rexy712 Date: Mon, 14 Jan 2019 12:57:36 -0800 Subject: [PATCH] Changed to cmake build system and now have install target --- .gitignore | 1 + CMakeLists.txt | 20 ++++++++++++ makefile | 86 -------------------------------------------------- 3 files changed, 21 insertions(+), 86 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 makefile diff --git a/.gitignore b/.gitignore index 53b50d7..228f52b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ temp *.d tester roflcat +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..57299d4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +include(CMakeDependentOption) +cmake_minimum_required(VERSION 3.1) +project(roflcat) + +#c++17 without compiler extensions +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +find_package(Curses REQUIRED) +set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include) + +add_executable (roflcat src/roflcat.cpp src/cmd.cpp) +target_include_directories(roflcat PUBLIC ${INCLUDE_PATH}) +target_include_directories(roflcat PUBLIC ${CURSES_INCLUDE_DIRS}) +target_link_libraries(roflcat PRIVATE ${CURSES_LIBRARIES}) +install(TARGETS roflcat RUNTIME DESTINATION bin) + +#uninstall target +add_custom_target(uninstall cat install_manifest.txt | xargs rm) diff --git a/makefile b/makefile deleted file mode 100644 index 55be8c6..0000000 --- a/makefile +++ /dev/null @@ -1,86 +0,0 @@ -#This program is free software: you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation, either version 3 of the License, or -#(at your option) any later version. - -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. - -#You should have received a copy of the GNU General Public License -#along with this program. If not, see . - -#Copyright 2018-2019 rexy712 - - -SOURCE_DIRS:=src -OBJDIR:=obj -DEPDIR:=$(OBJDIR)/dep -INCLUDE_DIRS:=include -EXT:=cpp -MAIN_EXECUTABLE:=roflcat - -CXX:=g++ -CXXFLAGS:=-g -std=c++17 -Wall -pedantic -Wextra -fno-exceptions -fno-rtti -all: CXXFLAGS+=-O0 -release: CXXFLAGS+=-O2 -LDFLAGS= -LDLIBS:=-lncurses -STRIP:=strip - -memchk:LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -memchk:CXXFLAGS+=-O0 -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls - -ifeq ($(OS),Windows_NT) - mkdir=mkdir $(subst /,\,$(1)) > NUL 2>&1 - rm=del /F $(1) > NUL 2>&1 - rmdir=rd /s /q $(1) > NUL 2>&1 - move=move /y $(subst /,\,$(1)) $(subst /,\,$(2)) > NUL 2>&1 - MAIN_EXECUTABLE:=$(MAIN_EXECUTABLE).exe - LDLIBS:=-lncurses -else - mkdir=mkdir -p $(1) - rm=rm -f $(1) - rmdir=rm -rf $(1) - move=mv $(1) $(2) -endif - -INTERNAL_CXXFLAGS=-c $(foreach dir,$(INCLUDE_DIRS),-I"$(dir)") -MMD -MP -MF"$(DEPDIR)/$(notdir $(patsubst %.o,%.d,$@))" -SOURCES:=$(foreach source,$(SOURCE_DIRS),$(foreach ext,$(EXT),$(wildcard $(source)/*.$(ext)))) -OBJECTS:=$(addprefix $(OBJDIR)/,$(subst \,.,$(subst /,.,$(addsuffix .o,$(SOURCES))))) - -all: $(MAIN_EXECUTABLE) -memchk: $(MAIN_EXECUTABLE) - -$(MAIN_EXECUTABLE): $(OBJECTS) - $(CXX) $(LDFLAGS) $^ -o "$(basename $@)" $(LDLIBS) - -.PHONY: release -release: $(OBJECTS) - $(CXX) $(LDFLAGS) $^ -o "$(basename $(MAIN_EXECUTABLE))" $(LDLIBS) - $(STRIP) --strip-all "$(MAIN_EXECUTABLE)" - -define GENERATE_OBJECTS - -$$(OBJDIR)/$(subst \,.,$(subst /,.,$(1))).%.o: $(1)/% - $$(CXX) $$(CXXFLAGS) $$(INTERNAL_CXXFLAGS) "$$<" -o "$$@" - -endef - -$(foreach dir,$(SOURCE_DIRS),$(eval $(call GENERATE_OBJECTS,$(dir)))) -$(OBJECTS): | $(OBJDIR) $(DEPDIR) - -$(OBJDIR): - $(call mkdir,"$@") -$(DEPDIR): - $(call mkdir,"$@") - -.PHONY: clean -clean: - $(call rmdir,"$(DEPDIR)") - $(call rmdir,"$(OBJDIR)") - $(call rm,"$(MAIN_EXECUTABLE)") - --include $(wildcard $(DEPDIR)/*.d) -