-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
61 lines (52 loc) · 1.53 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 最低版本
cmake_minimum_required(VERSION 2.8)
# 工程名称
project(eddyserver C CXX)
# 编译类型
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# 编译选项
if (LINUX)
set(CMAKE_CXX_FLAGS
-g
-Wall
-Wextra
-Werror
-Wconversion
-Wno-unused-parameter
-Wold-style-cast
-Woverloaded-virtual
-Wpointer-arith
-Wshadow
-Wwrite-strings
-std=c++1y
)
endif()
# 输出目录
set(BINARY_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BINARY_OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BINARY_OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BINARY_OUTPUT_DIR})
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BINARY_OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BINARY_OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BINARY_OUTPUT_DIR})
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
add_definitions(-DBINARY_OUTPUT_DIR="${BINARY_OUTPUT_DIR}")
# 开启分组
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
# 配置asio
if (WIN32)
add_definitions(-DASIO_MSVC)
endif()
add_definitions(-DASIO_STANDALONE)
set(ASIO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include)
# 配置eddyserver
set(EDDYSERVER_LIBRARY eddyserver)
set(EDDYSERVER_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/eddyserver)
# 编译eddyserver
add_subdirectory(eddyserver)
# 编译示例代码
add_subdirectory(examples/echo)