-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
executable file
·156 lines (145 loc) · 4.19 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
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
146
147
148
149
150
151
152
153
154
155
156
cmake_minimum_required(VERSION 2.8)
project(enet_example)
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
# CMAKE extensions
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${enet_example_SOURCE_DIR}/cmake")
# Required packages
find_package(ENet REQUIRED)
find_package(Epoxy REQUIRED)
find_package(GLM REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
# Warning pedantic flags for all
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wpedantic -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
# Dependencies and include locations
include_directories("include")
include_directories("external/include")
include_directories(${ENET_INCLUDE_DIRS})
include_directories(${EPOXY_INCLUDE_DIRS})
include_directories(${GLM_INCLUDE_DIR})
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${SDL2_INCLUDE_DIR})
## Client Executable
# Add source files
set(client_sources
"src/enet/ENetClient"
"src/game/Camera"
"src/game/Environment"
"src/game/Frame"
"src/game/Idle"
"src/game/Image"
"src/game/MoveDirection"
"src/game/MoveTo"
"src/game/Player"
"src/game/State"
"src/game/StateMachine"
"src/game/StateType"
"src/game/Terrain"
"src/geometry/Cube"
"src/geometry/Geometry"
"src/geometry/Intersection"
"src/geometry/Octree"
"src/geometry/Sphere"
"src/geometry/Triangle"
"src/gl/GLInfo"
"src/gl/Shader"
"src/gl/Texture2D"
"src/gl/TextureCubeMap"
"src/gl/ElementArrayBufferObject"
"src/gl/VertexAttributePointer"
"src/gl/VertexBufferObject"
"src/gl/VertexArrayObject"
"src/gl/VertexFragmentShader"
"src/gl/Uniform"
"src/gl/UniformDescriptor"
"src/gl/UniformBlockDescriptor"
"src/gl/Viewport"
"src/input/Input"
"src/input/Keyboard"
"src/input/KeyboardEvent"
"src/input/Mouse"
"src/input/MouseEvent"
"src/input/Window"
"src/log/Log"
"src/math/Math"
"src/math/Transform"
"src/net/Client"
"src/net/Message"
"src/render/Material"
"src/render/Mesh"
"src/render/Node"
"src/render/RenderCommand"
"src/render/Renderer"
"src/render/Technique"
"src/sdl/SDL2Keyboard"
"src/sdl/SDL2Mouse"
"src/sdl/SDL2Window"
"src/serial/Serialization"
"src/serial/StreamBuffer"
"src/time/Time"
"src/client")
# Construct the executable
add_executable(client ${client_sources})
# Link the executable to libraries
target_link_libraries(client
${ENET_LIBRARIES}
${EPOXY_LIBRARIES}
${SDL2_LIBRARY}
${OPENGL_LIBRARIES})
## Server Executable
# Add source files
set(server_sources
"src/enet/ENetServer"
"src/game/Environment"
"src/game/Frame"
"src/game/Idle"
"src/game/Image"
"src/game/MoveDirection"
"src/game/MoveTo"
"src/game/Player"
"src/game/State"
"src/game/StateMachine"
"src/game/StateType"
"src/game/Terrain"
"src/geometry/Geometry"
"src/geometry/Intersection"
"src/geometry/Octree"
"src/geometry/Triangle"
"src/gl/ElementArrayBufferObject"
"src/gl/GLInfo"
"src/gl/Texture2D"
"src/gl/VertexArrayObject"
"src/gl/VertexAttributePointer"
"src/gl/VertexBufferObject"
"src/input/Input"
"src/log/Log"
"src/math/Math"
"src/math/Transform"
"src/net/Server"
"src/net/Message"
"src/serial/Serialization"
"src/serial/StreamBuffer"
"src/time/Time"
"src/server")
# Construct the executable
add_executable(server ${server_sources})
# Link the executable to libraries
target_link_libraries(server
${ENET_LIBRARIES}
${EPOXY_LIBRARIES}
${SDL2_LIBRARY}
${OPENGL_LIBRARIES})
# Additional target to perform clang-format, requires clang-format
file(GLOB_RECURSE all_sources include/*.h src/*.cpp)
add_custom_target(fmt
COMMAND clang-format -style=WebKit -i ${all_sources})
# Copy resource dir to build
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/resources/
DESTINATION
${CMAKE_CURRENT_BINARY_DIR}/resources/)