forked from rktrlng/rt2d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
474 lines (433 loc) · 12.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
474 lines (433 loc) · 12.7 KB
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
# CMake entry point
cmake_minimum_required (VERSION 2.6)
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_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(USE_RS232 "Use RS232 library" ON)
OPTION(MAKE_SERIAL "Make serial application" ON)
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)
# On Visual 2005 and above, this module can set the debug working directory
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-1c73e35")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP
if(MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSE(MINGW)
add_definitions( "/W1 /D_CRT_SECURE_NO_WARNINGS /wd4514 /nologo" ) # suppress pedantic warnings
endif(MINGW)
endif(WIN32)
# Compile external dependencies
find_package(OpenGL REQUIRED)
add_subdirectory (external)
include_directories(
${CMAKE_SOURCE_DIR}/external/glfw-3.0.3/include/GLFW
${CMAKE_SOURCE_DIR}/external/glm-0.9.8.4
${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.0.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_303
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/scene07.cpp
projects/demo/scene07.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/scene11.cpp
projects/demo/scene11.h
projects/demo/scene12.cpp
projects/demo/scene12.h
projects/demo/scene13.cpp
projects/demo/scene13.h
projects/demo/scene14.cpp
projects/demo/scene14.h
projects/demo/scene15.cpp
projects/demo/scene15.h
projects/demo/scene16.cpp
projects/demo/scene16.h
projects/demo/scene17.cpp
projects/demo/scene17.h
projects/demo/scene18.cpp
projects/demo/scene18.h
projects/demo/scene19.cpp
projects/demo/scene19.h
projects/demo/scene20.cpp
projects/demo/scene20.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()
####################################################################
# 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()
####################################################################
# 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()
####################################################################