From 2db8b53d442f4b8a7b49128233d34431e83cdb17 Mon Sep 17 00:00:00 2001 From: xiaozhuai <798047000@qq.com> Date: Sun, 14 May 2017 20:08:47 +0800 Subject: [PATCH] add CMakeLists.txt for linux and osx --- .gitignore | 4 ++++ CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ README.md | 16 +++++++++++++++- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 7a7d3da..9d11153 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ Release/ *.sdf *.opensdf *.suo +.idea +build/ +*~ +.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..12e7ba1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.8) +project(DesignPattern) + +set(CMAKE_CXX_STANDARD 11) + + +set(PATTERNS + AbstractFactoryPattern + AdapterPattern + BridgePattern + BuilderPattern + ChainOfResponsibilityPattern + CommandPattern + CompositePattern + DecoratorPattern + FacadePattern + FactoryPattern + FlyweightPattern + InterpreterPattern + IteratorPattern + MediatorPattern + MementoPattern + ObserverPattern + PrototypePattern + ProxyPattern + SingletonPattern + StatePattern + StrategyPattern + TemplatePattern + VisitorPattern) + +macro(add_pattern PATTERN) + include_directories(${PATTERN}) + file(GLOB_RECURSE PATTERN_FILES "${PATTERN}/*.cpp") + add_executable(${PATTERN} ${PATTERN_FILES}) +endmacro(add_pattern) + +foreach(PATTERN IN LISTS PATTERNS) + message(STATUS "Found Pattern: ${PATTERN}") + add_pattern(${PATTERN}) +endforeach(PATTERN) + diff --git a/README.md b/README.md index 475086e..341b592 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,18 @@ *NOTE:源代码经过简化,移除了一些不必要的构造和析构函数,方便阅读* -**编译器**:Visual Studio 2013(MSVC 12) \ No newline at end of file +# 编译 + +## Visual Studio 2013(MSVC 12) +使用 Visual Studio 导入项目即可编译 + +## Linux or Mac OSX +Linux 或 Mac OSX 环境使用 cmake 编译 + +```bash +$ cd /path/to/project +$ mkdir build +$ cd build +$ cmake .. +$ make +``` \ No newline at end of file -- Gitee