-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathCMakeLists.txt
576 lines (529 loc) · 15.9 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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
# CMake entry point
cmake_minimum_required (VERSION 3.12)
project (rt2d)
# delete CMakeCache.txt from the build directory when you edit these options
####################################################################
OPTION(MAKE_START "Make RT2D start application" ON)
OPTION(MAKE_DEMO "Make RT2D demo (tests) application" ON)
OPTION(MAKE_CANVAS_DEMO "Make RT2D Canvas demo (tests) application" ON)
OPTION(MAKE_FLOCKING "Make flocking application" ON)
OPTION(MAKE_BASIC3D "Make basic3D application" ON)
OPTION(MAKE_NOISE "Make Perlin Noise application" ON)
OPTION(MAKE_GEOMETRIC "Make GeoMetric application" ON)
OPTION(MAKE_SHADY "Make custom Shader application" ON)
OPTION(MAKE_WOLFENSTEIN "Make Wolfenstein3D raycasting application" ON)
OPTION(MAKE_COLLISION "Make Collision application" ON)
OPTION(MAKE_DEBUGDRAW "Make DebugDraw application" ON)
OPTION(MAKE_RAYCAST "Make Raycast application" ON)
OPTION(MAKE_MATRIXPIXEL "Make MatrixPixel application" ON)
OPTION(USE_RS232 "Use RS232 library" OFF)
OPTION(MAKE_SERIAL "Make serial application" OFF)
OPTION(USE_OPENAL "Use OpenAL library" OFF)
OPTION(MAKE_AUDIOSTART "Make OpenAL/RT2D audiostart" OFF)
OPTION(MAKE_OPENAL_TONEGEN "Make OpenAL Tone Generator" OFF)
OPTION(USE_BOX2D "Use Box2D" OFF)
OPTION(MAKE_BOX2DSTART "Make Box2D/RT2D box2dstart" OFF)
####################################################################
if( CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR )
message( FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like 'build')" )
endif()
if( CMAKE_SOURCE_DIR MATCHES " " )
message( "Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if( CMAKE_BINARY_DIR MATCHES " " )
message( "Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if(UNIX)
#set(CMAKE_CXX_FLAGS "-Wall -std=c++0x -pedantic -O2 -g -pg")
#set(CMAKE_CXX_FLAGS "-Wall -Wstrict-aliasing -std=c++0x -O2")
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -O2")
# valgrind --leak-check=full ./demo
# ./demo # creates cmon.out
# gprof demo gmon.out > analysis.txt
#set(CMAKE_CXX_FLAGS "-Wall -pg -std=c++11")
endif(UNIX)
if(WIN32)
# suppress pedantic warnings
add_definitions( "/W1 /D_CRT_SECURE_NO_WARNINGS /wd4514 /nologo" )
endif(WIN32)
# Compile external dependencies
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
add_subdirectory (external)
include_directories(
${CMAKE_SOURCE_DIR}/external/glfw-3.3/include/GLFW
${CMAKE_SOURCE_DIR}/external/glm-0.9.9.2
${CMAKE_SOURCE_DIR}/external/glew-1.9.0/include
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/rt2d
${CMAKE_SOURCE_DIR}/.
)
link_directories(
${CMAKE_SOURCE_DIR}/external/glfw-3.3/src
${CMAKE_SOURCE_DIR}/external/glew-1.9.0
${CMAKE_SOURCE_DIR}/external
${CMAKE_SOURCE_DIR}/rt2d
)
set(ALL_GRAPHICS_LIBS
${OPENGL_LIBRARY}
rt2d
glfw
GLEW_190
)
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
####################################################################
# librt2d.a #
####################################################################
add_library(rt2d
rt2d/camera.cpp
rt2d/camera.h
rt2d/canvas.cpp
rt2d/canvas.h
rt2d/color.h
rt2d/core.cpp
rt2d/core.h
rt2d/entity.cpp
rt2d/entity.h
rt2d/input.cpp
rt2d/input.h
rt2d/line.cpp
rt2d/line.h
rt2d/mesh.cpp
rt2d/mesh.h
rt2d/noise.cpp
rt2d/noise.h
rt2d/pointx.h
rt2d/renderer.cpp
rt2d/renderer.h
rt2d/resourcemanager.cpp
rt2d/resourcemanager.h
rt2d/rt2dconfig.h
rt2d/scene.cpp
rt2d/scene.h
rt2d/shader.cpp
rt2d/shader.h
rt2d/sprite.cpp
rt2d/sprite.h
rt2d/text.cpp
rt2d/text.h
rt2d/texture.cpp
rt2d/texture.h
rt2d/timer.cpp
rt2d/timer.h
rt2d/util.c
rt2d/util.h
rt2d/vectorx.h
)
file(
COPY ${CMAKE_SOURCE_DIR}/rt2d/shaders
DESTINATION ${CMAKE_BINARY_DIR}
)
file(
COPY ${CMAKE_SOURCE_DIR}/rt2d/fonts
DESTINATION ${CMAKE_BINARY_DIR}
)
####################################################################
# start #
####################################################################
IF(MAKE_START)
add_executable(start
start/main.cpp
start/myentity.cpp
start/myentity.h
start/myscene.cpp
start/myscene.h
)
target_link_libraries(start
${ALL_GRAPHICS_LIBS}
)
# Copy assets to the build directory
file(
COPY start/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# demo #
####################################################################
IF(MAKE_DEMO)
add_executable(demo
projects/demo/main.cpp
projects/demo/basicentity.cpp
projects/demo/basicentity.h
projects/demo/scene00.cpp
projects/demo/scene00.h
projects/demo/scene01.cpp
projects/demo/scene01.h
projects/demo/scene02.cpp
projects/demo/scene02.h
projects/demo/scene03.cpp
projects/demo/scene03.h
projects/demo/scene03a.cpp
projects/demo/scene03a.h
projects/demo/scene04.cpp
projects/demo/scene04.h
projects/demo/scene05.cpp
projects/demo/scene05.h
projects/demo/scene06.cpp
projects/demo/scene06.h
projects/demo/scene06a.cpp
projects/demo/scene06a.h
projects/demo/scene08.cpp
projects/demo/scene08.h
projects/demo/scene09.cpp
projects/demo/scene09.h
projects/demo/scene10.cpp
projects/demo/scene10.h
projects/demo/scene18.cpp
projects/demo/scene18.h
projects/demo/scene21.cpp
projects/demo/scene21.h
projects/demo/scene22.cpp
projects/demo/scene22.h
projects/demo/scene23.cpp
projects/demo/scene23.h
projects/demo/superscene.cpp
projects/demo/superscene.h
)
target_link_libraries(demo
${ALL_GRAPHICS_LIBS}
)
# Copy assets to the build directory
file(
COPY projects/demo/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# canvasdemo #
####################################################################
IF(MAKE_CANVAS_DEMO)
add_executable(canvasdemo
projects/canvasdemo/main.cpp
projects/canvasdemo/basicentity.cpp
projects/canvasdemo/basicentity.h
projects/canvasdemo/scene07.cpp
projects/canvasdemo/scene07.h
projects/canvasdemo/scene11.cpp
projects/canvasdemo/scene11.h
projects/canvasdemo/scene12.cpp
projects/canvasdemo/scene12.h
projects/canvasdemo/scene13.cpp
projects/canvasdemo/scene13.h
projects/canvasdemo/scene14.cpp
projects/canvasdemo/scene14.h
projects/canvasdemo/scene15.cpp
projects/canvasdemo/scene15.h
projects/canvasdemo/scene16.cpp
projects/canvasdemo/scene16.h
projects/canvasdemo/scene17.cpp
projects/canvasdemo/scene17.h
projects/canvasdemo/scene19.cpp
projects/canvasdemo/scene19.h
projects/canvasdemo/scene20.cpp
projects/canvasdemo/scene20.h
projects/canvasdemo/superscene.cpp
projects/canvasdemo/superscene.h
)
target_link_libraries(canvasdemo
${ALL_GRAPHICS_LIBS}
)
# Copy assets to the build directory
file(
COPY projects/canvasdemo/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# Cube #
####################################################################
IF(MAKE_BASIC3D)
add_executable(basic3D
projects/basic3D/main.cpp
projects/basic3D/cube.cpp
projects/basic3D/cube.h
projects/basic3D/myscene.cpp
projects/basic3D/myscene.h
)
target_link_libraries(basic3D
${ALL_GRAPHICS_LIBS}
)
# Copy assets to the build directory
file(
COPY projects/basic3D/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# Noise #
####################################################################
IF(MAKE_NOISE)
add_executable(noise
projects/perlinnoise/main.cpp
projects/perlinnoise/myscene.cpp
projects/perlinnoise/myscene.h
)
target_link_libraries(noise
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# geometric #
####################################################################
IF(MAKE_GEOMETRIC)
add_executable(geometric
projects/geometric/main.cpp
projects/geometric/geometric.cpp
projects/geometric/geometric.h
projects/geometric/myscene.cpp
projects/geometric/myscene.h
)
target_link_libraries(geometric
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# slim shady #
####################################################################
IF(MAKE_SHADY)
add_executable(slimshady
projects/slimshady/main.cpp
projects/slimshady/myentity.cpp
projects/slimshady/myentity.h
projects/slimshady/myscene.cpp
projects/slimshady/myscene.h
)
target_link_libraries(slimshady
${ALL_GRAPHICS_LIBS}
)
# Copy shaders to the build directory
file(
COPY projects/slimshady/shaders
DESTINATION ${CMAKE_BINARY_DIR}
)
# Copy assets to the build directory
file(
COPY projects/slimshady/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# flocking #
####################################################################
IF(MAKE_FLOCKING)
add_executable(flocking
projects/flocking/boid.cpp
projects/flocking/flock.cpp
projects/flocking/scene01.cpp
projects/flocking/main.cpp
)
target_link_libraries(flocking
${ALL_GRAPHICS_LIBS}
)
# Copy assets to the build directory
file(
COPY projects/flocking/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# Wolfenstein3D #
####################################################################
IF(MAKE_WOLFENSTEIN)
add_executable(wolfenstein
projects/wolfenstein/wolfenstein.cpp
projects/wolfenstein/main.cpp
)
target_link_libraries(wolfenstein
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# collision #
####################################################################
IF(MAKE_COLLISION)
add_executable(collision
projects/collision/main.cpp
projects/collision/shape.cpp
projects/collision/shape.h
projects/collision/myscene.cpp
projects/collision/myscene.h
)
target_link_libraries(collision
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# DebugDraw #
####################################################################
IF(MAKE_DEBUGDRAW)
add_executable(debugdraw
projects/debugdraw/main.cpp
projects/debugdraw/myscene.cpp
projects/debugdraw/myscene.h
)
target_link_libraries(debugdraw
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# raycast #
####################################################################
IF(MAKE_RAYCAST)
add_executable(raycast
projects/raycast/main.cpp
projects/raycast/myscene.cpp
projects/raycast/myscene.h
)
target_link_libraries(raycast
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# matrixpixel #
####################################################################
IF(MAKE_MATRIXPIXEL)
add_executable(matrixpixel
projects/matrixpixel/math/matrix4.h
projects/matrixpixel/math/matrix4.cpp
projects/matrixpixel/math/vector4.h
projects/matrixpixel/math/vector4.cpp
projects/matrixpixel/main.cpp
projects/matrixpixel/scene01.cpp
projects/matrixpixel/scene01.h
)
target_link_libraries(matrixpixel
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################
# librs232.a #
####################################################################
IF(USE_RS232)
include_directories(
${CMAKE_SOURCE_DIR}/external/rs232
)
link_directories(
${CMAKE_SOURCE_DIR}/external/rs232
)
add_library( rs232 STATIC
external/rs232/rs232.c
external/rs232/rs232.h
)
ENDIF()
####################################################################
# serial #
####################################################################
IF(MAKE_SERIAL AND USE_RS232)
add_executable(serial
projects/serial/main.cpp
projects/serial/myscene.cpp
projects/serial/myscene.h
)
target_link_libraries(serial
${ALL_GRAPHICS_LIBS}
rs232
)
ENDIF()
####################################################################
# OpenAL #
####################################################################
IF(USE_OPENAL)
add_subdirectory (external/openal)
include_directories(
${CMAKE_SOURCE_DIR}/external/openal/include/
)
link_directories(
${CMAKE_SOURCE_DIR}/external/openal/
)
IF(WIN32)
SET(OPENAL OpenAL32)
ELSE()
SET(OPENAL openal)
ENDIF()
ENDIF()
####################################################################
# RT2D/OpenAL audiostart #
####################################################################
IF(MAKE_AUDIOSTART AND USE_OPENAL)
add_executable(audiostart
projects/audiostart/main.cpp
projects/audiostart/myentity.cpp
projects/audiostart/myentity.h
projects/audiostart/myscene.cpp
projects/audiostart/myscene.h
projects/audiostart/audio/audio.cpp
projects/audiostart/audio/audio.h
projects/audiostart/audio/sound.cpp
projects/audiostart/audio/sound.h
projects/audiostart/audio/wav.cpp
projects/audiostart/audio/wav.h
)
target_link_libraries(audiostart
${ALL_GRAPHICS_LIBS}
${OPENAL}
)
# Copy assets to the build directory
file(
COPY projects/audiostart/assets
DESTINATION ${CMAKE_BINARY_DIR}
)
ENDIF()
####################################################################
# OpenAL tone generator #
####################################################################
IF(MAKE_OPENAL_TONEGEN AND USE_OPENAL)
add_executable(altonegenrt
external/openal/examples/altonegen.c
external/openal/examples/common/alhelpers.c
)
target_link_libraries(altonegenrt
${OPENAL}
)
ENDIF()
####################################################################
# box2d.a #
####################################################################
IF(USE_BOX2D)
option(BOX2D_INSTALL "Install Box2D libs, includes, and CMake scripts" OFF)
option(BOX2D_INSTALL_DOC "Install Box2D documentation" OFF)
option(BOX2D_BUILD_SHARED "Build Box2D shared libraries" OFF)
option(BOX2D_BUILD_STATIC "Build Box2D static libraries" ON)
option(BOX2D_BUILD_EXAMPLES "Build Box2D examples" OFF)
set(BOX2D_VERSION 2.3.2)
set(LIB_INSTALL_DIR lib${LIB_SUFFIX})
# The Box2D library.
add_subdirectory(external/Box2D)
include_directories(
${CMAKE_SOURCE_DIR}/external/Box2D
)
link_directories(
${CMAKE_SOURCE_DIR}/external/Box2D
)
add_definitions(
-DBOX2D_BUILD_STATIC
)
set(BOX2D_LIB
Box2D
)
ENDIF()
####################################################################
# Box2D/RT2D box2dstart #
####################################################################
IF(MAKE_BOX2DSTART AND USE_BOX2D)
add_executable(box2dstart
projects/box2dstart/main.cpp
projects/box2dstart/scene01.cpp
)
target_link_libraries (box2dstart
${BOX2D_LIB}
${ALL_GRAPHICS_LIBS}
)
ENDIF()
####################################################################