-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
48 lines (38 loc) · 1.42 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
# Copyright (C) 2012-present ichenq@outlook.com All rights reserved.
# Distributed under the terms and conditions of the Apache License.
# See accompanying files LICENSE.
cmake_minimum_required(VERSION 3.0)
project(WinsockTut)
include_directories(
src
)
add_definitions(
-DNOMINMAX
-DWIN32_LEAN_AND_MEAN
-D_WIN32_WINNT=0x0600
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_WINSOCK_DEPRECATED_NO_WARNINGS
-DFD_SETSIZE=1024
)
file(GLOB_RECURSE LIB_HEADER_FILES src/*.h)
file(GLOB_RECURSE LIB_SOURCE_FILES src/*.cpp)
macro(SOURCE_GROUP_BY_DIR source_files)
set(sgbd_cur_dir ${CMAKE_CURRENT_SOURCE_DIR})
foreach(sgbd_file ${${source_files}})
string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${sgbd_file})
string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
if(sgbd_nogroup)
set(sgbd_group_name "\\")
endif(sgbd_nogroup)
source_group(${sgbd_group_name} FILES ${sgbd_file})
endforeach(sgbd_file)
endmacro(SOURCE_GROUP_BY_DIR)
SOURCE_GROUP_BY_DIR(LIB_HEADER_FILES)
SOURCE_GROUP_BY_DIR(LIB_SOURCE_FILES)
add_library(libwinet ${LIB_HEADER_FILES} ${LIB_SOURCE_FILES})
target_link_libraries(libwinet ws2_32 mswsock)
add_subdirectory(examples/echo)
add_subdirectory(examples/pingpong)