-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
114 lines (99 loc) · 2.33 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
cmake_minimum_required(VERSION 3.10)
project(drawboard)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(SDL2 REQUIRED)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if(MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive -Wl,-Bdynamic \
")
endif()
add_subdirectory(thirdparty/flatbuffers
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
EXCLUDE_FROM_ALL
)
include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
add_executable(drawboard
main.cpp
client/client_app.cpp
client/draw_client.cpp
server/draw_server.cpp
server/transmit_worker.cpp
socket/read_write_buffer.cpp
socket/tcp_listener.cpp
socket/tcp_socket.cpp
common/abstract_canvas.cpp
common/log.cpp
common/packet.cpp
common/threaded_worker.cpp
)
if(WIN32)
target_sources(drawboard
PRIVATE
DeclareDPIAware.manifest
socket/tcp_listener_winsock.cpp
socket/tcp_socket_winsock.cpp
)
else()
target_sources(drawboard
PRIVATE
socket/tcp_listener_posix.cpp
socket/tcp_socket_posix.cpp
)
endif()
target_include_directories(drawboard
PRIVATE
thirdparty/argh
${SDL2_INCLUDE_DIRS}
)
# The flatbuffers target carry header search path automatically if CMake > 2.8.11.
target_link_libraries(drawboard
PRIVATE
flatbuffers
)
if(MSVC)
# SDL linkage for MSVC
target_link_libraries(drawboard
PRIVATE
SDL2::SDL2
SDL2::SDL2main
)
elseif(MINGW)
# SDL linkage for MinGW: Enable full static link
target_link_libraries(drawboard
PRIVATE
-Wl,-Bstatic
SDL2
SDL2main
-Wl,-Bdynamic
)
else()
# SDL linkage for other platforms: dynamic link by default
target_link_libraries(drawboard
PRIVATE
${SDL2_LIBRARIES}
)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# pthread is needed for gcc
target_link_libraries(drawboard
PRIVATE
pthread
)
endif()
if(WIN32)
target_link_libraries(drawboard
PRIVATE
Imm32
Winmm
Version
SetupAPI
Ws2_32
)
endif()