Newer
Older
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.15)
project(Lama) # your project name
set(CMAKE_CXX_STANDARD 20)
include_directories(sockpp/include)
find_package(wxWidgets COMPONENTS core base net REQUIRED)
include(${wxWidgets_USE_FILE})
# define a variable CLIENT_SOURCE_FILES that contains the paths to all source files required to compile the client executable
set(CLIENT_SOURCE_FILES
src/client/main.cpp
src/client/app/Lama.cpp src/client/app/Lama.h
src/client/GameController.cpp src/client/GameController.h
# UI
src/client/windows/GameWindow.cpp src/client/windows/GameWindow.h
src/client/uiElements/ImagePanel.cpp src/client/uiElements/ImagePanel.h
src/client/panels/ConnectionPanel.cpp src/client/panels/ConnectionPanel.h
src/client/panels/MainGamePanel.cpp src/client/panels/MainGamePanel.h
src/client/uiElements/InputField.cpp src/client/uiElements/InputField.h
src/client/uiElements/ImagePanel.cpp src/client/uiElements/ImagePanel.h
# network
src/client/network/ClientNetworkManager.cpp src/client/network/ClientNetworkManager.h
src/client/network/ResponseListenerThread.cpp src/client/network/ResponseListenerThread.h
# game state
src/common/game_state/cards/card.cpp src/common/game_state/cards/card.h
src/common/game_state/game_state.cpp src/common/game_state/game_state.h
src/common/game_state/player/hand.cpp src/common/game_state/player/hand.h
src/common/game_state/player/player.cpp src/common/game_state/player/player.h
src/common/game_state/cards/draw_pile.cpp src/common/game_state/cards/draw_pile.h
src/common/game_state/cards/discard_pile.cpp src/common/game_state/cards/discard_pile.h
# client requests
src/common/network/requests/client_request.cpp src/common/network/requests/client_request.h
src/common/network/requests/play_card_request.cpp src/common/network/requests/play_card_request.h
src/common/network/requests/draw_card_request.cpp src/common/network/requests/draw_card_request.h
src/common/network/requests/fold_request.cpp src/common/network/requests/fold_request.h
src/common/network/requests/join_game_request.cpp src/common/network/requests/join_game_request.h
src/common/network/requests/start_game_request.cpp src/common/network/requests/start_game_request.h
# server responses
src/common/network/responses/server_response.cpp src/common/network/responses/server_response.h
src/common/network/responses/request_response.cpp src/common/network/responses/request_response.h
src/common/network/responses/full_state_response.cpp src/common/network/responses/full_state_response.h
# serialization
src/common/serialization/serializable.h
src/common/serialization/value_type_helpers.h
src/common/serialization/vector_utils.h
src/common/serialization/serializable_value.h
src/common/serialization/json_utils.h
src/common/serialization/uuid_generator.h
src/common/serialization/unique_serializable.cpp src/common/serialization/unique_serializable.h)
# define a variable SERVER_SOURCE_FILES that contains the paths to all source files required to compile the server executable
set(SERVER_SOURCE_FILES
src/server/main.cpp
src/server/game_instance.cpp src/server/game_instance.h
src/server/game_instance_manager.cpp src/server/game_instance_manager.h
src/server/player_manager.cpp src/server/player_manager.h
src/server/server_network_manager.cpp src/server/server_network_manager.h
# game state
src/common/game_state/cards/card.cpp src/common/game_state/cards/card.h
src/common/game_state/game_state.cpp src/common/game_state/game_state.h
src/common/game_state/player/hand.cpp src/common/game_state/player/hand.h
src/common/game_state/player/player.cpp src/common/game_state/player/player.h
src/common/game_state/cards/draw_pile.cpp src/common/game_state/cards/draw_pile.h
src/common/game_state/cards/discard_pile.cpp src/common/game_state/cards/discard_pile.h
# client requests
src/common/network/requests/client_request.cpp src/common/network/requests/client_request.h
src/common/network/requests/play_card_request.cpp src/common/network/requests/play_card_request.h
src/common/network/requests/draw_card_request.cpp src/common/network/requests/draw_card_request.h
src/common/network/requests/fold_request.cpp src/common/network/requests/fold_request.h
src/common/network/requests/join_game_request.cpp src/common/network/requests/join_game_request.h
src/common/network/requests/start_game_request.cpp src/common/network/requests/start_game_request.h
# server responses
src/common/network/responses/server_response.cpp src/common/network/responses/server_response.h
src/common/network/responses/request_response.cpp src/common/network/responses/request_response.h
src/common/network/responses/full_state_response.cpp src/common/network/responses/full_state_response.h
# serialization
src/common/serialization/serializable.h
src/common/serialization/value_type_helpers.h
src/common/serialization/vector_utils.h
src/common/serialization/serializable_value.h
src/common/serialization/json_utils.h
src/common/serialization/uuid_generator.h
src/common/serialization/unique_serializable.cpp src/common/serialization/unique_serializable.h src/server/request_handler.h src/server/request_handler.cpp)
# set source files for client-executable
add_executable(Lama-client ${CLIENT_SOURCE_FILES})
# set compile directives for client-executable
target_compile_definitions(Lama-client PRIVATE LAMA_CLIENT=1 RAPIDJSON_HAS_STDSTRING=1)
# link with wxWidgets
target_link_libraries(Lama-client ${wxWidgets_LIBRARIES})
# Comment out if you don't want to print network-related messages into the console
target_compile_definitions(Lama-client PRIVATE PRINT_NETWORK_MESSAGES=1)
# set source files for server-executable
add_executable(Lama-server ${SERVER_SOURCE_FILES})
# set compile directives for server-executable
target_compile_definitions(Lama-server PRIVATE LAMA_SERVER=1 RAPIDJSON_HAS_STDSTRING=1)
# Comment out if you don't want to print network-related messages into the console
target_compile_definitions(Lama-server PRIVATE PRINT_NETWORK_MESSAGES=1)
# linking to sockpp
if(WIN32)
message("Detected Win32")
target_link_libraries(Lama-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/sockpp-static.lib)
target_link_libraries(Lama-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/sockpp-static.lib)
# Necessary to get sockets working under Windows (with MingW)
target_link_libraries(Lama-client wsock32 ws2_32)
elseif(APPLE)
message("Detected macOS")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Lama-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads)
target_link_libraries(Lama-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.dylib Threads::Threads)
else()
message("Not Win32 or macOS, so probably Linux")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(Lama-client ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads)
target_link_libraries(Lama-server ${CMAKE_SOURCE_DIR}/sockpp/cmake-build-debug/libsockpp.so Threads::Threads)
endif()
# copy assets (images) to binary directory
file(INSTALL assets DESTINATION ${CMAKE_BINARY_DIR})
set(CMAKE_CXX_FLAGS "--coverage")
# set source files for server-library
add_library(Lama-lib ${SERVER_SOURCE_FILES})
# set compile directives for server-library
target_compile_definitions(Lama-lib PRIVATE LAMA_SERVER=1 RAPIDJSON_HAS_STDSTRING=1)
add_subdirectory(googletest)
add_subdirectory(unit-tests)