-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
422 lines (351 loc) · 13.8 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# CMake Version
cmake_minimum_required(VERSION 2.8)
include(CMakeDependentOption)
# Project Name
project(NordicEngine)
# OSX RPATH
set(CMAKE_MACOSX_RPATH 0)
# Options
option(NordicEngine_OSOnly "OS Only" OFF)
option(NordicEngine_UnitTest "Unit Tests" OFF)
option(NordicEngine_FullEngine "Full Engine" OFF)
# NOS Files
set(NE ${PROJECT_SOURCE_DIR}/NordicEngine)
set(LibHeaders ${NE}/Engine.hpp)
set(LibSources ${NE}/Engine.cpp)
# Set Third Party Directory
set(NET ${PROJECT_SOURCE_DIR}/NordicEngine/ThirdParty)
# NOS Includes
list(APPEND LibHeaders ${NE}/Includes.hpp)
# link path
link_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR})
################################################################
########################### OS STUFF ###########################
################################################################
link_directories(${NE}/OS)
include_directories(${NE}/OS)
list(APPEND LibHeaders ${NE}/OS/OS.hpp)
# OS Specific Classes
if (WIN32)
link_directories(${NE}/OS/Windows)
include_directories(${NE}/OS/Windows)
list(APPEND LibHeaders ${NE}/OS/Windows/Windows.hpp)
list(APPEND LibSources ${NE}/OS/Windows/Windows.cpp)
else()
# nonWindows
link_directories(${NE}/OS/nonWindows)
include_directories(${NE}/OS/nonWindows)
list(APPEND LibHeaders ${NE}/OS/nonWindows/nonWindows.hpp)
if (APPLE)
# C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 --stdlib=libc++ -m64")
set(EXTRA_FLAGS " -x objective-c++")
link_directories(${NE}/OS/nonWindows/OSX)
include_directories(${NE}/OS/nonWindows/OSX)
list(APPEND LibHeaders ${NE}/OS/nonWindows/OSX/OSX.hpp)
list(APPEND LibHeaders ${NE}/OS/nonWindows/OSX/OSX.mm)
# Apple Libs
link_directories(/usr/local/include)
include_directories(/usr/local/include)
elseif (UNIX)
# C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -m64")
set(EXTRA_FLAGS "")
link_directories(${NE}/OS/nonWindows/Linux)
include_directories(${NE}/OS/nonWindows/Linux)
list(APPEND LibHeaders ${NE}/OS/nonWindows/Linux/Linux.hpp)
list(APPEND LibSources ${NE}/OS/nonWindows/Linux/Linux.cpp)
endif()
endif()
####################################################################
########################### ALL COMPILES ###########################
####################################################################
# String
link_directories(${NE}/String)
include_directories(${NE}/String)
list(APPEND LibHeaders ${NE}/String/String.hpp)
list(APPEND LibHeaders ${NE}/String/String.inl)
list(APPEND LibSources ${NE}/String/String.cpp)
# Time
link_directories(${NE}/Time)
include_directories(${NE}/Time)
list(APPEND LibHeaders ${NE}/Time/Time.hpp)
list(APPEND LibSources ${NE}/Time/Time.cpp)
# Logger
link_directories(${NE}/Logger)
include_directories(${NE}/Logger)
list(APPEND LibHeaders ${NE}/Logger/Logger.hpp)
list(APPEND LibSources ${NE}/Logger/Logger.cpp)
# Exceptions
link_directories(${NE}/Exception)
include_directories(${NE}/Exception)
list(APPEND LibHeaders ${NE}/Exception/Exception.hpp)
list(APPEND LibSources ${NE}/Exception/Exception.cpp)
# Files
link_directories(${NE}/Files)
include_directories(${NE}/Files)
list(APPEND LibHeaders ${NE}/Files/Loader.hpp)
list(APPEND LibSources ${NE}/Files/Loader.cpp)
list(APPEND LibHeaders ${NE}/Files/Handler.hpp)
list(APPEND LibSources ${NE}/Files/Handler.cpp)
list(APPEND LibHeaders ${NE}/Files/Utils.hpp)
list(APPEND LibSources ${NE}/Files/Utils.cpp)
# TextFile
link_directories(${NE}/Files/Format/TextFile)
include_directories(${NE}/Files/Format/TextFile)
list(APPEND LibHeaders ${NE}/Files/Format/TextFile/Writer.hpp)
list(APPEND LibSources ${NE}/Files/Format/TextFile/Writer.cpp)
list(APPEND LibHeaders ${NE}/Files/Format/TextFile/Reader.hpp)
list(APPEND LibSources ${NE}/Files/Format/TextFile/Reader.cpp)
# Lua
link_directories(${NE}/Files/Format/Lua)
include_directories(${NE}/Files/Format/Lua)
list(APPEND LibHeaders ${NE}/Files/Format/Lua/Lua.hpp)
list(APPEND LibSources ${NE}/Files/Format/Lua/Lua.cpp)
# Threads
link_directories(${NE}/Threading/Threads)
include_directories(${NE}/Threading/Threads)
list(APPEND LibHeaders ${NE}/Threading/Threads/Threads.hpp)
list(APPEND LibSources ${NE}/Threading/Threads/Threads.cpp)
# Singleton
link_directories(${NE}/Threading/Singleton)
include_directories(${NE}/Threading/Singleton)
list(APPEND LibHeaders ${NE}/Threading/Singleton/Singleton.hpp)
list(APPEND LibSources ${NE}/Threading/Singleton/Singleton.cpp)
# Noise
link_directories(${NE}/Noise)
include_directories(${NE}/Noise)
list(APPEND LibHeaders ${NE}/Noise/Simplex.hpp)
list(APPEND LibSources ${NE}/Noise/Simplex.cpp)
# Storage
link_directories(${NE}/Storage)
include_directories(${NE}/Storage)
list(APPEND LibHeaders ${NE}/Storage/Storage.hpp)
list(APPEND LibSources ${NE}/Storage/Storage.cpp)
# Utilitys
link_directories(${NE}/Utility)
include_directories(${NE}/Utility)
list(APPEND LibHeaders ${NE}/Utility/Utility.hpp)
list(APPEND LibSources ${NE}/Utility/Utility.cpp)
list(APPEND LibHeaders ${NE}/Utility/Maths.hpp)
list(APPEND LibSources ${NE}/Utility/Maths.cpp)
list(APPEND LibHeaders ${NE}/Utility/Seeder.hpp)
list(APPEND LibSources ${NE}/Utility/Seeder.cpp)
list(APPEND LibHeaders ${NE}/Utility/Markov.hpp)
list(APPEND LibSources ${NE}/Utility/Markov.cpp)
list(APPEND LibHeaders ${NE}/Utility/NameGen.hpp)
list(APPEND LibSources ${NE}/Utility/NameGen.cpp)
# Color
link_directories(${NE}/Color)
include_directories(${NE}/Color)
list(APPEND LibHeaders ${NE}/Color/Color.hpp)
list(APPEND LibSources ${NE}/Color/Color.cpp)
#########################################################################
########################### FULL ENGINE STUFF ###########################
#########################################################################
if (NordicEngine_FullEngine)
# OpenGL
list(APPEND LibHeaders ${NE}/OS/OpenGL.hpp)
list(APPEND LibSources ${NE}/OS/OpenGL.cpp)
# Render
link_directories(${NE}/Render)
include_directories(${NE}/Render)
list(APPEND LibHeaders ${NE}/Render/Manager.hpp)
list(APPEND LibSources ${NE}/Render/Manager.cpp)
# Shader
link_directories(${NE}/Render/Shader)
include_directories(${NE}/Render/Shader)
list(APPEND LibHeaders ${NE}/Render/Shader/Shader.hpp)
list(APPEND LibSources ${NE}/Render/Shader/Shader.cpp)
# Shaders
link_directories(${NE}/Shaders)
include_directories(${NE}/Shaders)
list(APPEND LibHeaders ${NE}/Shaders/Simple.hpp)
list(APPEND LibSources ${NE}/Shaders/Simple.cpp)
# Model
link_directories(${NE}/Render/Models)
include_directories(${NE}/Render/Models)
list(APPEND LibHeaders ${NE}/Render/Models/Model.hpp)
list(APPEND LibSources ${NE}/Render/Models/Model.cpp)
list(APPEND LibHeaders ${NE}/Render/Models/Manager.hpp)
list(APPEND LibSources ${NE}/Render/Models/Manager.cpp)
# BitMap
link_directories(${NE}/Files/Format/BitMap)
include_directories(${NE}/Files/Format/BitMap)
list(APPEND LibHeaders ${NE}/Files/Format/BitMap/BitMap.hpp)
list(APPEND LibSources ${NE}/Files/Format/BitMap/BitMap.cpp)
# DDS
link_directories(${NE}/Files/Format/DDS)
include_directories(${NE}/Files/Format/DDS)
list(APPEND LibHeaders ${NE}/Files/Format/DDS/DDS.hpp)
list(APPEND LibSources ${NE}/Files/Format/DDS/DDS.cpp)
# Texture
link_directories(${NE}/Files/Texture)
include_directories(${NE}/Files/Texture)
list(APPEND LibHeaders ${NE}/Files/Texture/Texture.hpp)
list(APPEND LibSources ${NE}/Files/Texture/Texture.cpp)
# Obj
link_directories(${NE}/Files/Format/Obj)
include_directories(${NE}/Files/Format/Obj)
list(APPEND LibHeaders ${NE}/Files/Format/Obj/Obj.hpp)
list(APPEND LibSources ${NE}/Files/Format/Obj/Obj.cpp)
# Window
link_directories(${NE}/Window)
include_directories(${NE}/Window)
list(APPEND LibHeaders ${NE}/Window/Window.hpp)
list(APPEND LibSources ${NE}/Window/Window.cpp)
# Window Manager
list(APPEND LibHeaders ${NE}/Window/Manager.hpp)
list(APPEND LibSources ${NE}/Window/Manager.cpp)
# Player
link_directories(${NE}/Player)
include_directorieS(${NE}/Player)
list(APPEND LibHeaders ${NE}/Player/Player.hpp)
list(APPEND LibSources ${NE}/Player/Player.cpp)
# Input
link_directories(${NE}/Input)
include_directories(${NE}/Input)
list(APPEND LibHeaders ${NE}/Input/Definitions.hpp)
list(APPEND LibHeaders ${NE}/Input/Input.hpp)
list(APPEND LibSources ${NE}/Input/Input.cpp)
# Camera
link_directories(${NE}/Camera)
include_directories(${NE}/Camera)
list(APPEND LibHeaders ${NE}/Camera/Camera.hpp)
list(APPEND LibSources ${NE}/Camera/Camera.cpp)
# Light
link_directories(${NE}/Light)
include_directories(${NE}/Light)
list(APPEND LibHeaders ${NE}/Light/Light.hpp)
list(APPEND LibSources ${NE}/Light/Light.cpp)
# Settings
link_directories(${NE}/Settings)
include_directories(${NE}/Settings)
list(APPEND LibHeaders ${NE}/Settings/Settings.hpp)
list(APPEND LibSources ${NE}/Settings/Settings.cpp)
# 2D Text
link_directories(${NE}/Render/Text)
include_directories(${NE}/Render/Text)
list(APPEND LibHeaders ${NE}/Render/Text/Text.hpp)
list(APPEND LibSources ${NE}/Render/Text/Text.cpp)
endif()
########################################################################
########################### THIRD PARTY BITS ###########################
########################################################################
# Boost
#find_package(Boost COMPONENTS locale REQUIRED)
#include_directories(${Boost_INCLUDES})
# Full Engine Deps
if (NordicEngine_FullEngine)
# GLFW
link_directories(${NET}/glfw)
include_directories(${NET}/glfw/include)
add_subdirectory(${NET}/glfw)
# GLEW
find_package(GLEW REQUIRED)
link_directories(${GLEW_INCLUDES})
include_directories(${GLEW_INCLUDES})
endif()
# SQLite
link_directories(${NET}/sqlite)
include_directories(${NET}/sqlite)
add_subdirectory(${NET}/sqlite)
# GLM
link_directories(${NET}/glm)
include_directories(${NET}/glm)
#add_subdirectory(${NET}/glm)
# STB
link_directories(${NET}/stb)
include_directories(${NET}/stb)
#add_subdirectory(${NET}/stb)
# Lua
add_subdirectory(${NET}/lua)
link_directories(${NET}/lua)
include_directories(${NET}/lua)
link_directories(${NET}/lua/lua)
include_directories(${NET}/lua/lua)
# Lua Bridge
link_directories(${NET}/LuaBridge/Source/LuaBridge)
include_directories(${NET}/LuaBridge/Source/LuaBridge)
list(APPEND LibHeaders ${NET}/LuaBridge/Source/LuaBridge/LuaBridge.h)
# ZLib
link_directories(${NET}/miniz)
include_directories(${NET}/miniz)
add_subdirectory(${NET}/miniz)
# JSON
link_directories(${NET}/jsonxx)
include_directories(${NET}/jsonxx)
list(APPEND LibHeaders ${NET}/jsonxx/jsonxx.h)
list(APPEND LibSources ${NET}/jsonxx/jsonxx.cc)
#########################################################################
########################### BUILD THE LIBRARY ###########################
#########################################################################
# Build Number
list(APPEND LibHeaders ${NE}/buildNumber.hpp)
# Set for Exports
set(NordicEngine_Libraries ${LibSources})
set(NordicEngine_Headers ${LibHeaders})
# Generate Library
add_library(NordicEngine SHARED ${LibSources} ${LibHeaders})
set_target_properties(NordicEngine PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(NordicEngine PROPERTIES OUTPUT_NAME "NordicEngine")
########################################################################
########################### LINK THE LIBRARY ###########################
########################################################################
# System Linker
if(NordicEngine_FullEngine)
if (WIN32)
target_link_libraries(NordicEngine ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
elseif (APPLE)
target_link_libraries(NordicEngine "-framework OpenGL -framework OpenAL -framework GameKit -framework GLKit -framework CoreVideo")
else()
target_link_libraries(NordicEngine ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
endif()
endif()
# Universal ones
if (WIN32)
target_link_libraries(NordicEngine winmm gdi32)
elseif (APPLE)
target_link_libraries(NordicEngine "-framework Foundation -framework AppKit -framework IOKit -framework Carbon -framework CoreFoundation" c++abi)
else()
target_link_libraries(NordicEngine ${X11_X11_LIB} ${X11_Xrandr_LIB} c++abi)
endif()
# Library Linker
if (NordicEngine_FullEngine)
target_link_libraries(NordicEngine glfw ${GLFW_LIBRARIES})
target_link_libraries(NordicEngine ${GLEW_LIBRARIES})
endif()
# Universal links
target_link_libraries(NordicEngine SQLite)
#target_link_libraries(NordicEngine ${Boost_LIBRARIES})
target_link_libraries(NordicEngine liblua ${LUA_LIBRARIES})
target_link_libraries(NordicEngine MiniZ)
##################################################################
########################### UNIT TESTS ###########################
##################################################################
# Unit Tests
if (NordicEngine_UnitTest)
project(UnitTests)
SET(UT ${PROJECT_SOURCE_DIR}/Tests)
link_directories(${UT})
include_directories(${UT})
set(TestHeaders ${UT}/Main.hpp)
if (NordicEngine_OSOnly)
set(TestSources ${UT}/OSTests.cpp)
elseif (NordicEngine_FullEngine)
set(TestSources ${UT}/FullTests.cpp)
else()
set(TestSources ${UT}/Tests.cpp)
endif()
# Test Framework
link_directories(${UT}/Catch)
include_directories(${UT}/Catch)
list(APPEND TestHeaders ${UT}/Catch/catch.hpp)
# Build Test Binary
add_executable(UnitTests ${TestSources} ${TestHeaders})
set_target_properties(UnitTests PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(UnitTests PROPERTIES OUTPUT_NAME "UnitTests.app")
# Link Unit Tests to which ever NordicEngine was build
target_link_libraries(UnitTests NordicEngine)
endif()