-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
611 lines (544 loc) · 21.3 KB
/
CMakeLists.txt
File metadata and controls
611 lines (544 loc) · 21.3 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
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
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
cmake_minimum_required(VERSION 3.16)
project(ESEngine VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(ES_BUILD_WEB "Build for Web/Emscripten" OFF)
option(ES_BUILD_WXGAME "Build for WeChat MiniGame" OFF)
option(ES_BUILD_TESTS "Build tests" ON)
option(ES_BUILD_SINGLE_FILE "Build single-file SDK (WASM inlined)" OFF)
option(ES_ENABLE_SPINE "Enable Spine animation support" ON)
option(ES_ENABLE_BOX2D "Enable Box2D physics support" OFF)
option(ES_ENABLE_TILEMAP "Enable Tilemap support" ON)
option(ES_ENABLE_PARTICLES "Enable Particle system" ON)
option(ES_ENABLE_TIMELINE "Enable Timeline animation" ON)
option(ES_ENABLE_POSTPROCESS "Enable Post-processing pipeline" ON)
option(ES_ENABLE_BITMAP_TEXT "Enable Bitmap text rendering" ON)
option(ES_BUILD_MAIN_MODULE "Build as MAIN_MODULE for dynamic linking" OFF)
option(ES_BUILD_SIDE_MODULE "Build side modules for dynamic linking" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ESEngineConfig)
include(CompilerCache)
if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
include(Emscripten)
endif()
add_subdirectory(third_party)
# =============================================================================
# ESEngine Library
# =============================================================================
set(ESENGINE_SOURCES
src/esengine/core/Engine.cpp
src/esengine/core/EstellaContext.cpp
src/esengine/core/Log.cpp
src/esengine/resource/ResourceManager.cpp
src/esengine/resource/ShaderParser.cpp
src/esengine/renderer/RenderContext.cpp
src/esengine/renderer/Renderer.cpp
src/esengine/renderer/Shader.cpp
src/esengine/renderer/Buffer.cpp
src/esengine/renderer/Texture.cpp
src/esengine/renderer/Framebuffer.cpp
src/esengine/renderer/RenderFrame.cpp
src/esengine/renderer/RenderFrameMask.cpp
src/esengine/renderer/RenderFrameSubmit.cpp
src/esengine/renderer/FrameCapture.cpp
src/esengine/renderer/RenderTarget.cpp
src/esengine/renderer/ImmediateDraw.cpp
src/esengine/renderer/CustomGeometry.cpp
src/esengine/renderer/GLDevice.cpp
src/esengine/renderer/StateTracker.cpp
src/esengine/renderer/TransientBufferPool.cpp
src/esengine/renderer/DrawList.cpp
src/esengine/renderer/plugins/SpritePlugin.cpp
src/esengine/renderer/plugins/UIElementPlugin.cpp
src/esengine/renderer/plugins/TextPlugin.cpp
src/esengine/renderer/plugins/ShapePlugin.cpp
src/esengine/platform/input/Input.cpp
src/esengine/platform/PathResolver.cpp
src/esengine/animation/TweenSystem.cpp
src/esengine/ecs/UILayoutSystem.cpp
src/esengine/ecs/UISystem.cpp
)
if(ES_ENABLE_POSTPROCESS)
list(APPEND ESENGINE_SOURCES
src/esengine/renderer/PostProcessPipeline.cpp
)
endif()
if(ES_ENABLE_TILEMAP)
list(APPEND ESENGINE_SOURCES
src/esengine/renderer/plugins/TilemapRenderPlugin.cpp
src/esengine/tilemap/TilemapSystem.cpp
src/esengine/tilemap/TiledMapLoader.cpp
)
endif()
if(ES_ENABLE_PARTICLES)
list(APPEND ESENGINE_SOURCES
src/esengine/renderer/plugins/ParticlePlugin.cpp
src/esengine/particle/Particle.cpp
src/esengine/particle/ParticleSystem.cpp
)
endif()
if(ES_ENABLE_TIMELINE)
list(APPEND ESENGINE_SOURCES
src/esengine/animation/TimelineSystem.cpp
)
endif()
list(APPEND ESENGINE_SOURCES
src/esengine/text/BitmapFont.cpp
)
if(ES_ENABLE_SPINE)
list(APPEND ESENGINE_SOURCES
src/esengine/spine/SpineExtension.cpp
src/esengine/spine/SpineResourceManager.cpp
src/esengine/spine/SpineSystem.cpp
src/esengine/renderer/plugins/SpinePlugin.cpp
)
endif()
set(ESENGINE_HEADERS
src/esengine/ESEngine.hpp
src/esengine/core/Types.hpp
src/esengine/core/Engine.hpp
src/esengine/core/Log.hpp
src/esengine/core/Reflection.hpp
src/esengine/core/ServiceRegistry.hpp
src/esengine/ecs/Entity.hpp
src/esengine/ecs/ComponentMask.hpp
src/esengine/ecs/Component.hpp
src/esengine/ecs/System.hpp
src/esengine/ecs/Registry.hpp
src/esengine/ecs/SparseSet.hpp
src/esengine/ecs/View.hpp
src/esengine/ecs/TransformSystem.hpp
src/esengine/ecs/components/Transform.hpp
src/esengine/ecs/components/Hierarchy.hpp
src/esengine/ecs/components/Sprite.hpp
src/esengine/ecs/components/Camera.hpp
src/esengine/ecs/components/Velocity.hpp
src/esengine/ecs/components/Common.hpp
src/esengine/ecs/components/SpineAnimation.hpp
src/esengine/ecs/components/BitmapText.hpp
src/esengine/math/Math.hpp
src/esengine/resource/Handle.hpp
src/esengine/resource/ResourcePool.hpp
src/esengine/resource/ResourceManager.hpp
src/esengine/resource/Resource.hpp
src/esengine/renderer/RenderContext.hpp
src/esengine/renderer/Renderer.hpp
src/esengine/renderer/Shader.hpp
src/esengine/renderer/Buffer.hpp
src/esengine/renderer/Texture.hpp
src/esengine/renderer/Framebuffer.hpp
src/esengine/renderer/RenderStage.hpp
src/esengine/renderer/RenderItem.hpp
src/esengine/renderer/RenderTarget.hpp
src/esengine/renderer/RenderFrame.hpp
src/esengine/renderer/ImmediateDraw.hpp
src/esengine/renderer/BlendMode.hpp
src/esengine/renderer/CustomGeometry.hpp
src/esengine/renderer/GfxEnums.hpp
src/esengine/renderer/GfxDevice.hpp
src/esengine/renderer/GLDevice.hpp
src/esengine/renderer/StateTracker.hpp
src/esengine/renderer/TransientBufferPool.hpp
src/esengine/renderer/DrawCommand.hpp
src/esengine/renderer/DrawList.hpp
src/esengine/renderer/ClipState.hpp
src/esengine/renderer/RenderTypePlugin.hpp
src/esengine/renderer/plugins/SpritePlugin.hpp
src/esengine/renderer/plugins/UIElementPlugin.hpp
src/esengine/renderer/plugins/TextPlugin.hpp
src/esengine/renderer/plugins/ShapePlugin.hpp
src/esengine/renderer/plugins/SpinePlugin.hpp
src/esengine/platform/Platform.hpp
src/esengine/platform/FileSystem.hpp
src/esengine/platform/input/Input.hpp
src/esengine/events/Events.hpp
src/esengine/events/Connection.hpp
src/esengine/events/Signal.hpp
src/esengine/events/Sink.hpp
src/esengine/events/Dispatcher.hpp
src/esengine/animation/TweenData.hpp
src/esengine/animation/EasingFunctions.hpp
src/esengine/animation/TweenSystem.hpp
)
if(ES_ENABLE_POSTPROCESS)
list(APPEND ESENGINE_HEADERS
src/esengine/renderer/PostProcessPipeline.hpp
)
endif()
if(ES_ENABLE_TILEMAP)
list(APPEND ESENGINE_HEADERS
src/esengine/renderer/plugins/TilemapRenderPlugin.hpp
src/esengine/tilemap/TilemapSystem.hpp
src/esengine/tilemap/TiledMapLoader.hpp
)
endif()
if(ES_ENABLE_PARTICLES)
list(APPEND ESENGINE_HEADERS
src/esengine/renderer/plugins/ParticlePlugin.hpp
src/esengine/particle/ParticleSystem.hpp
)
endif()
if(ES_ENABLE_TIMELINE)
list(APPEND ESENGINE_HEADERS
src/esengine/animation/TimelineData.hpp
src/esengine/animation/TimelineSystem.hpp
)
endif()
list(APPEND ESENGINE_HEADERS
src/esengine/text/BitmapFont.hpp
)
if(ES_ENABLE_SPINE)
list(APPEND ESENGINE_HEADERS
src/esengine/spine/SpineExtension.hpp
src/esengine/spine/SpineResourceManager.hpp
src/esengine/spine/SpineSystem.hpp
)
endif()
list(APPEND ESENGINE_HEADERS
src/esengine/ecs/components/RigidBody.hpp
src/esengine/ecs/components/Collider.hpp
)
set(GENERATED_WEB_BINDINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/esengine/bindings/WebBindings.generated.cpp")
set(GENERATED_EDITOR_API "${CMAKE_CURRENT_SOURCE_DIR}/src/esengine/bindings/EditorAPI.generated.cpp")
set(GENERATED_TS_DEFINITIONS "${CMAKE_CURRENT_SOURCE_DIR}/sdk/src/wasm.generated.ts")
if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
list(APPEND ESENGINE_SOURCES
src/esengine/platform/web/WebPlatform.cpp
src/esengine/platform/web/WebFileSystem.cpp
)
else()
list(APPEND ESENGINE_SOURCES
src/esengine/platform/native/NativePlatform.cpp
src/esengine/platform/native/NativeFileSystem.cpp
src/esengine/platform/FileDialog.cpp
src/esengine/renderer/stb_image_impl.cpp
src/esengine/resource/LoaderJobQueue.cpp
src/esengine/resource/HotReloadManager.cpp
src/esengine/resource/loaders/ShaderLoader.cpp
)
list(APPEND ESENGINE_HEADERS
src/esengine/platform/native/NativePlatform.hpp
src/esengine/platform/FileDialog.hpp
)
endif()
# =============================================================================
# EHT - ESEngine Header Tool
# =============================================================================
find_package(Python3 COMPONENTS Interpreter)
if(Python3_FOUND)
file(GLOB_RECURSE COMPONENT_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/src/esengine/ecs/components/*.hpp"
)
add_custom_command(
OUTPUT ${GENERATED_WEB_BINDINGS} ${GENERATED_TS_DEFINITIONS}
COMMAND ${Python3_EXECUTABLE}
"${CMAKE_CURRENT_SOURCE_DIR}/tools/eht.py"
--input "${CMAKE_CURRENT_SOURCE_DIR}/src/esengine/ecs/components"
--output "${CMAKE_CURRENT_SOURCE_DIR}/src/esengine/bindings"
--ts-output "${CMAKE_CURRENT_SOURCE_DIR}/sdk/src"
DEPENDS ${COMPONENT_HEADERS} "${CMAKE_CURRENT_SOURCE_DIR}/tools/eht.py"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running EHT..."
VERBATIM
)
add_custom_target(eht DEPENDS ${GENERATED_WEB_BINDINGS} ${GENERATED_TS_DEFINITIONS})
message(STATUS "EHT: ENABLED")
else()
message(WARNING "Python3 not found - EHT DISABLED")
endif()
add_library(esengine STATIC ${ESENGINE_SOURCES} ${ESENGINE_HEADERS})
if(Python3_FOUND)
add_dependencies(esengine eht)
endif()
target_include_directories(esengine
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/third_party/stb
)
target_link_libraries(esengine PUBLIC glm yogacore)
if(ES_ENABLE_TILEMAP)
target_link_libraries(esengine PUBLIC cute_tiled)
target_compile_definitions(esengine PUBLIC ES_ENABLE_TILEMAP)
endif()
if(ES_ENABLE_PARTICLES)
target_compile_definitions(esengine PUBLIC ES_ENABLE_PARTICLES)
endif()
if(ES_ENABLE_TIMELINE)
target_compile_definitions(esengine PUBLIC ES_ENABLE_TIMELINE)
endif()
if(ES_ENABLE_POSTPROCESS)
target_compile_definitions(esengine PUBLIC ES_ENABLE_POSTPROCESS)
endif()
if(ES_ENABLE_BITMAP_TEXT)
target_compile_definitions(esengine PUBLIC ES_ENABLE_BITMAP_TEXT)
endif()
if(ES_ENABLE_SPINE)
target_link_libraries(esengine PUBLIC spine-cpp)
target_compile_definitions(esengine PUBLIC ES_ENABLE_SPINE)
endif()
if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
target_compile_options(esengine PRIVATE ${ES_EMSCRIPTEN_COMPILE_FLAGS})
target_compile_definitions(esengine PUBLIC ES_PLATFORM_WEB)
if(ES_BUILD_WXGAME)
target_compile_definitions(esengine PUBLIC ES_PLATFORM_WXGAME)
endif()
else()
find_package(OpenGL REQUIRED)
target_compile_definitions(esengine PUBLIC ES_PLATFORM_NATIVE ES_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
target_link_libraries(esengine PUBLIC glfw glad OpenGL::GL nlohmann_json)
target_include_directories(esengine PUBLIC ${CMAKE_SOURCE_DIR}/third_party/glad/include)
if(WIN32)
target_compile_definitions(esengine PUBLIC ES_PLATFORM_WINDOWS)
endif()
endif()
esengine_set_strict_warnings(esengine)
# =============================================================================
# Web SDK
# =============================================================================
if(ES_BUILD_WEB OR ES_BUILD_WXGAME)
set(SDK_BINDING_SOURCES
src/esengine/bindings/WebSDKEntry.cpp
src/esengine/bindings/EngineContext.cpp
src/esengine/bindings/ResourceManagerBindings.cpp
src/esengine/bindings/RendererBindings.cpp
src/esengine/bindings/ImmediateDrawBindings.cpp
src/esengine/bindings/GeometryBindings.cpp
${GENERATED_WEB_BINDINGS}
${GENERATED_EDITOR_API}
)
if(ES_ENABLE_POSTPROCESS)
list(APPEND SDK_BINDING_SOURCES src/esengine/bindings/PostProcessBindings.cpp)
endif()
if(ES_ENABLE_TILEMAP)
list(APPEND SDK_BINDING_SOURCES src/esengine/bindings/TilemapBindings.cpp)
endif()
if(ES_ENABLE_TIMELINE)
list(APPEND SDK_BINDING_SOURCES src/esengine/bindings/TimelineBindings.cpp)
endif()
add_executable(esengine_sdk ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_sdk PRIVATE esengine)
es_apply_sdk_settings(esengine_sdk)
set_target_properties(esengine_sdk PROPERTIES
OUTPUT_NAME "esengine"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
# Single-file SDK (WASM inlined as Base64, for playable ads)
if(ES_BUILD_SINGLE_FILE)
add_executable(esengine_single ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_single PRIVATE esengine)
es_apply_single_file_settings(esengine_single)
set_target_properties(esengine_single PROPERTIES
OUTPUT_NAME "esengine.single"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
# Generate playable ad HTML template
file(WRITE "${CMAKE_BINARY_DIR}/sdk/playable.html.in" [=[
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name="ad.size" content="width=320,height=480">
<title>Playable</title>
<style>
*{margin:0;padding:0;box-sizing:border-box}
html,body{width:100%;height:100%;overflow:hidden;background:#1a1a1a}
#canvas{display:block;width:100%;height:100%;touch-action:none}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
// ESEngine Single-File SDK will be inlined here
// SDK_PLACEHOLDER
</script>
<script>
(function(){
function resizeCanvas(){
var c=document.getElementById('canvas');
var dpr=window.devicePixelRatio||1;
c.width=window.innerWidth*dpr;
c.height=window.innerHeight*dpr;
}
window.addEventListener('resize',resizeCanvas);
resizeCanvas();
ESEngineModule({
canvas:document.getElementById('canvas'),
print:function(t){console.log(t)},
printErr:function(t){console.error(t)}
}).then(function(Module){
var Registry=new Module.Registry();
Module.initRenderer();
// Create camera
var cam=Registry.create();
Registry.addCamera(cam,{projectionType:1,fov:60,orthoSize:400,nearPlane:0.1,farPlane:1000,aspectRatio:1,isActive:true,priority:0});
Registry.addLocalTransform(cam,{position:{x:0,y:0,z:10},rotation:{w:1,x:0,y:0,z:0},scale:{x:1,y:1,z:1}});
// Create sprite
var spr=Registry.create();
Registry.addSprite(spr,{texture:0,color:{x:1,y:0.5,z:0.2,w:1},size:{x:100,y:100},uvOffset:{x:0,y:0},uvScale:{x:1,y:1},layer:0,flipX:false,flipY:false});
Registry.addLocalTransform(spr,{position:{x:0,y:0,z:0},rotation:{w:1,x:0,y:0,z:0},scale:{x:1,y:1,z:1}});
var start=performance.now();
function loop(){
var t=(performance.now()-start)/1000;
var tr=Registry.getLocalTransform(spr);
tr.position.x=Math.sin(t)*100;
tr.position.y=Math.cos(t)*100;
var vp=window.innerWidth*(window.devicePixelRatio||1);
var vh=window.innerHeight*(window.devicePixelRatio||1);
Module.renderFrame(Registry,vp,vh);
requestAnimationFrame(loop);
}
loop();
});
})();
</script>
</body>
</html>
]=])
endif()
# Core-only SDK (no Spine, for modular builds)
if(NOT ES_ENABLE_SPINE)
set_target_properties(esengine_sdk PROPERTIES
OUTPUT_NAME "esengine-core"
)
endif()
# WeChat MiniGame SDK (CommonJS compatible)
if(ES_BUILD_WXGAME)
add_executable(esengine_wxgame ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_wxgame PRIVATE esengine)
es_apply_wxgame_sdk_settings(esengine_wxgame)
set_target_properties(esengine_wxgame PROPERTIES
OUTPUT_NAME "esengine.wxgame"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
# Spine standalone WASM module (spine-c)
if(ES_ENABLE_SPINE)
file(GLOB_RECURSE SPINE_MODULE_SPINE_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-4.2/spine-c/spine-c/src/spine/*.c"
)
add_executable(spine_module
src/esengine/bindings/SpineModuleEntry.cpp
${SPINE_MODULE_SPINE_SOURCES}
)
target_include_directories(spine_module PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-4.2/spine-c/spine-c/include
)
es_apply_spine_module_settings(spine_module)
set_target_properties(spine_module PROPERTIES
OUTPUT_NAME "spine42"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
# Spine 4.1 standalone module (spine-c)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-4.1")
file(GLOB_RECURSE SPINE41_MODULE_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-4.1/spine-c/spine-c/src/spine/*.c"
)
add_executable(spine_module_41
src/esengine/bindings/SpineModuleEntry.cpp
${SPINE41_MODULE_SOURCES}
)
target_include_directories(spine_module_41 PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-4.1/spine-c/spine-c/include
)
target_compile_definitions(spine_module_41 PRIVATE ES_SPINE_41)
es_apply_spine_module_settings(spine_module_41)
set_target_properties(spine_module_41 PROPERTIES
OUTPUT_NAME "spine41"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
# Spine 3.8 standalone module (spine-c)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-3.8")
file(GLOB_RECURSE SPINE38_MODULE_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-3.8/spine-c/spine-c/src/spine/*.c"
)
add_executable(spine_module_38
src/esengine/bindings/SpineModuleEntry.cpp
${SPINE38_MODULE_SOURCES}
)
target_include_directories(spine_module_38 PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/spine-runtimes-3.8/spine-c/spine-c/include
)
target_compile_definitions(spine_module_38 PRIVATE ES_SPINE_38)
es_apply_spine_module_settings(spine_module_38)
set_target_properties(spine_module_38 PROPERTIES
OUTPUT_NAME "spine38"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
# Physics standalone WASM module
if(ES_ENABLE_BOX2D)
add_executable(physics_module
src/esengine/bindings/PhysicsModuleEntry.cpp
src/esengine/bindings/PhysicsContext.cpp
src/esengine/bindings/PhysicsShapes.cpp
src/esengine/bindings/PhysicsJoints.cpp
src/esengine/bindings/PhysicsQueries.cpp
)
target_link_libraries(physics_module PRIVATE box2d)
target_include_directories(physics_module PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/box2d/include
)
es_apply_physics_module_settings(physics_module)
set_target_properties(physics_module PROPERTIES
OUTPUT_NAME "physics"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
# Main module SDK (MAIN_MODULE=2, supports loading side modules)
if(ES_BUILD_MAIN_MODULE)
add_executable(esengine_sdk_main ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_sdk_main PRIVATE esengine)
es_apply_main_module_settings(esengine_sdk_main)
set_target_properties(esengine_sdk_main PROPERTIES
OUTPUT_NAME "esengine"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
if(ES_BUILD_WXGAME)
add_executable(esengine_wxgame_main ${SDK_BINDING_SOURCES})
target_link_libraries(esengine_wxgame_main PRIVATE esengine)
es_apply_wxgame_main_module_settings(esengine_wxgame_main)
set_target_properties(esengine_wxgame_main PROPERTIES
OUTPUT_NAME "esengine.wxgame"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
endif()
# Physics side module (SIDE_MODULE=2, pure .wasm, no JS glue)
if(ES_ENABLE_BOX2D AND ES_BUILD_SIDE_MODULE)
add_executable(physics_side_module
src/esengine/bindings/PhysicsModuleEntry.cpp
src/esengine/bindings/PhysicsContext.cpp
src/esengine/bindings/PhysicsShapes.cpp
src/esengine/bindings/PhysicsJoints.cpp
src/esengine/bindings/PhysicsQueries.cpp
)
target_link_libraries(physics_side_module PRIVATE box2d)
target_include_directories(physics_side_module PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/third_party/box2d/include
)
es_apply_physics_side_module_settings(physics_side_module)
set_target_properties(physics_side_module PROPERTIES
OUTPUT_NAME "physics"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdk"
)
endif()
endif()
if(ES_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
install(TARGETS esengine
EXPORT ESEngineTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
install(DIRECTORY src/esengine/ DESTINATION include/esengine FILES_MATCHING PATTERN "*.hpp")