-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
210 lines (171 loc) · 7.43 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# This file is part of X3D.
#
# X3D is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# X3D is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with X3D. If not, see <http:#www.gnu.org/licenses/>.
# Options:
# - XTARGET - system to build for ("pc" or "nspire")
# - X_LIB_PATH - location to install library (default /usr/local/lib)
# - X_HEADER_PATH - location to install header files (default /usr/local/include)
# - X_WITH_SDL - whether to use SDL as the video backend (automatically set for nspire and pc)
# - USE_TILIBS - link in tilibs for multiplayer connections to the calc
cmake_minimum_required(VERSION 3.1)
project(X3D CXX ASM)
if(NOT DEFINED XTARGET)
set(XTARGET "pc")
endif()
if(NOT DEFINED X_LIB_PATH)
set(X_LIB_PATH "/usr/local/lib")
endif()
if(NOT DEFINED X_HEADER_PATH)
set(X_HEADER_PATH "/usr/local/include")
endif()
if(NOT DEFINED USE_TILIBS)
set(USE_TILIBS "0")
endif()
if(${XTARGET} STREQUAL "pc")
set(CMAKE_CXX_FLAGS "-std=c++14 -fPIC -Wall -g -fsanitize=address -fsanitize=undefined -O2 -Wno-unused-result -rdynamic")
#set(CMAKE_CXX_FLAGS "-std=gnu99 -fPIC -Wall -O3 -g")
set(X_WITH_SDL "1")
elseif(${XTARGET} STREQUAL "nspire")
set(CMAKE_C_COMPILER nspire-gcc)
set(CMAKE_CXX_COMPILER nspire-gcc)
set(CMAKE_ASM_COMPILER nspire-as)
set(CMAKE_LI)
add_definitions(-D__nspire__)
set(CMAKE_CXX_FLAGS "-Wall -O3")
set(X_WITH_SDL "1")
endif()
include_directories(src/)
set(X_SOURCES
# dev
src/dev/console/AutoCompleter.cpp
src/dev/console/DefaultCommands.cpp
src/dev/console/Console.cpp
src/dev/console/TokenLexer.cpp
# dev/console
src/dev/console/ConsoleRenderer.cpp
# engine
src/engine/Engine.cpp
src/engine/EngineContext.cpp
src/engine/EngineQueue.cpp
src/engine/Init.cpp
# entity
# builtin
src/entity/builtin/WorldEntity.cpp
src/entity/builtin/DoorEntity.cpp
src/entity/EntityDictionary.cpp
src/entity/EntityDictionaryParser.cpp
src/entity/EntityManager.cpp
src/entity/EntityBuilder.cpp
# error
src/error/Error.cpp
src/error/Log.cpp
# geo
src/geo/BoundBox.cpp
src/geo/Frustum.cpp
src/geo/Plane.cpp
src/geo/Polygon3.cpp
src/geo/Ray3.cpp
src/geo/Vec3.cpp
# level
src/level/BrushModelBuilder.cpp
src/level/BspLevel.cpp
src/level/BspLevelLoader.cpp
src/level/BspModel.cpp
src/level/BspNode.cpp
src/level/BspRayTracer.cpp
src/level/CollisionHullBuilder.cpp
src/level/EntityModel.cpp
src/level/EntityModelLoader.cpp
src/level/Portal.cpp
src/level/PotentiallyVisibleSet.cpp
# math
src/math/Mat4x4.cpp
src/math/Quaternion.cpp
src/math/FastSqrt.cpp
src/math/Trig.cpp
# memory
src/memory/Alloc.cpp
src/memory/Cache.cpp
src/memory/Memory.cpp
src/memory/String.cpp
# object
src/render/Camera.cpp
# physics
src/physics/PhysicsEngine.cpp
src/physics/BoxColliderEngine.cpp
src/physics/BoxColliderMoveLogic.cpp
# render
src/render/WireframeLevelRenderer.cpp
src/render/ActiveEdge.cpp
src/render/Font.cpp
src/render/Palette.cpp
src/render/OldRenderer.cpp
src/render/Screen.cpp
src/render/Span.cpp
src/render/Surface.cpp
src/render/StatusBar.cpp
src/render/Texture.cpp
src/render/Viewport.cpp
# system
src/system/Clock.cpp
src/system/File.cpp
src/system/FilePath.cpp
src/system/FileReader.cpp
src/system/FileSystem.cpp
src/system/Keys.cpp
src/system/Mouse.cpp
src/system/PackFile.cpp
# util
src/util/Json.cpp
src/util/X_JsonParser.cpp
src/util/StopWatch.cpp
src/util/X_util.cpp
)
if(${XTARGET} STREQUAL "pc")
set(X_SOURCES ${X_SOURCES}
src/platform/platform_pc.cpp
)
if(${USE_TILIBS} STREQUAL "1")
message("Building with tilibs")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)
find_package(PkgConfig REQUIRED)
include_directories(/usr/include/tilp2)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
include_directories(${GLIB2_INCLUDE_DIRS})
set(X_SOURCES ${X_SOURCES}
src/platform/socket_pc_to_nspire.cpp
)
endif()
endif()
if(${XTARGET} STREQUAL "nspire")
set(X_SOURCES ${X_SOURCES}
src/render/span-arm.s
src/platform/platform_nspire.cpp
src/platform/nspire/NspireScreenDriver.cpp
)
endif()
if(DEFINED X_WITH_SDL)
find_package(SDL REQUIRED)
include_directories(SDL_INCLUDE_DIR)
set(X_SOURCES ${X_SOURCES}
src/platform/SDL.cpp
src/platform/SDL/SdlScreenDriver.cpp
src/entity/EntityDictionary.hpp src/entity/EntityDictionaryParser.cpp src/entity/EntityDictionaryParser.hpp src/entity/EntityDictionary.cpp src/level/LevelManager.hpp src/level/LevelManager.cpp src/entity/component/InputComponent.hpp src/memory/FixedSizeArray.hpp src/render/software/SoftwareRenderer.cpp src/render/software/SoftwareRenderer.hpp src/render/software/LevelRenderer.cpp src/render/software/LevelRenderer.hpp src/entity/EntityEvent.hpp src/memory/StringId.hpp src/memory/Crc32.hpp src/memory/Crc32.cpp src/entity/component/ComponentType.hpp src/memory/GroupAllocator.cpp src/memory/GroupAllocator.hpp src/entity/component/TransformComponent.cpp src/entity/system/IEntitySystem.hpp src/engine/GlobalConfiguration.hpp src/memory/Set.hpp src/entity/system/BrushModelSystem.hpp src/entity/system/CameraSystem.hpp src/entity/system/BoxColliderSystem.hpp src/entity/system/GenericComponentSystem.hpp src/util/StackTrace.cpp src/util/StackTrace.hpp src/entity/component/ScriptableComponent.cpp src/entity/component/ScriptableComponent.hpp src/hud/MessageQueue.cpp src/hud/MessageQueue.hpp src/entity/component/PhysicsComponent.hpp src/entity/builtin/TriggerEntity.cpp src/entity/builtin/TriggerEntity.hpp src/entity/system/PhysicsSystem.cpp src/entity/system/PhysicsSystem.hpp src/hud/OverlayRenderer.cpp src/hud/OverlayRenderer.hpp src/hud/EntityOverlay.cpp src/hud/EntityOverlay.hpp src/render/RenderingUtil.cpp src/render/RenderingUtil.hpp src/entity/component/PhysicsComponent.cpp src/entity/builtin/BoxEntity.cpp src/entity/component/RenderComponent.cpp src/entity/component/RenderComponent.hpp src/entity/system/RenderSystem.cpp src/entity/system/RenderSystem.hpp src/render/AffineTriangleFiller.cpp src/render/AffineTriangleFiller.hpp src/entity/system/ScriptableSystem.hpp src/geo/PolygonClipper.hpp)
endif()
add_library(X3D STATIC ${X_SOURCES})
install(TARGETS X3D ARCHIVE DESTINATION ${X_LIB_PATH})
install(DIRECTORY src/ DESTINATION ${X_HEADER_PATH}/X3D FILES_MATCHING PATTERN "*.h")
install(DIRECTORY src/ DESTINATION ${X_HEADER_PATH}/X3D FILES_MATCHING PATTERN "*.hpp")