-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathCMakeLists.txt
541 lines (450 loc) · 20 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
cmake_minimum_required (VERSION 3.10)
if(PLATFORM_ANDROID)
add_subdirectory(Android)
elseif(PLATFORM_LINUX)
add_subdirectory(Linux)
endif()
project(Diligent-NativeAppBase)
if(PLATFORM_WIN32)
set(SOURCE
src/Win32/WinMain.cpp
)
set(INCLUDE
include/Win32/Win32AppBase.hpp
)
if (DILIGENT_BUILD_WIN32_GUI_AS_CONSOLE)
list(APPEND SOURCE src/Win32/main.cpp)
endif()
function(add_win32_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_executable(${TARGET_NAME} ${SOURCE} ${INCLUDE} ${ASSETS})
if(NOT DILIGENT_BUILD_WIN32_GUI_AS_CONSOLE)
set_target_properties(${TARGET_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# libmingw32 must be included BEFORE Diligent-NativeAppBase that contains the definition of WinMain.
# otherwise WinMain will be stripped out of Diligent-NativeAppBase and will be unresolved.
target_link_libraries(${TARGET_NAME}
PRIVATE
mingw32
)
endif()
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_win32_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_UNIVERSAL_WINDOWS)
set(SOURCE
src/UWP/dummy.cpp
)
set(INCLUDE
include/UWP/UWPAppBase.hpp
)
# Windows Runtime types cannot be included into static libraries
# https://social.msdn.microsoft.com/Forums/en-US/269db513-64ef-4817-a025-43954f614eb3/lnk4264-why-are-static-libraries-not-recommended-when-authoring-windows-runtime-types?forum=winappswithnativecode
# So as a workaround, we will include all source files into the target app project
function(add_uwp_app TARGET_NAME SOURCE INCLUDE ASSETS)
get_target_property(NATIVE_APP_SOURCE_DIR Diligent-NativeAppBase SOURCE_DIR)
set(UWP_SOURCE
${NATIVE_APP_SOURCE_DIR}/src/UWP/Common/DeviceResources.cpp
${NATIVE_APP_SOURCE_DIR}/src/UWP/App.cpp
${NATIVE_APP_SOURCE_DIR}/src/UWP/UWPAppBase.cpp
)
set(UWP_INCLUDE
${NATIVE_APP_SOURCE_DIR}/src/UWP/Common/DeviceResources.h
${NATIVE_APP_SOURCE_DIR}/src/UWP/Common/DirectXHelper.h
${NATIVE_APP_SOURCE_DIR}/src/UWP/App.h
${NATIVE_APP_SOURCE_DIR}/include/UWP/UWPAppBase.hpp
${NATIVE_APP_SOURCE_DIR}/src/UWP/Common/StepTimer.h
)
add_executable(${TARGET_NAME} WIN32 ${SOURCE} ${INCLUDE} ${ASSETS} ${UWP_SOURCE} ${UWP_INCLUDE})
set_source_files_properties(${ASSETS} PROPERTIES VS_DEPLOYMENT_CONTENT 1)
target_include_directories(${TARGET_NAME}
PUBLIC
${NATIVE_APP_SOURCE_DIR}/Src/UWP
)
target_link_libraries(${TARGET_NAME} PRIVATE dxgi.lib)
source_group("UWP Common\\src" FILES ${UWP_SOURCE})
source_group("UWP Common\\include" FILES ${UWP_INCLUDE})
endfunction(add_uwp_app)
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_uwp_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_ANDROID)
set(SOURCE
src/Android/AndroidAppBase.cpp
)
set(INCLUDE
include/Android/AndroidAppBase.hpp
)
function(add_android_app TARGET_NAME SOURCE INCLUDE ASSETS)
get_target_property(NATIVE_APP_SOURCE_DIR Diligent-NativeAppBase SOURCE_DIR)
set(ANDROID_SOURCE
${NATIVE_APP_SOURCE_DIR}/src/Android/AndroidMain.cpp
)
add_library(${TARGET_NAME} SHARED ${SOURCE} ${ANDROID_SOURCE} ${INCLUDE} ${ASSETS})
target_link_libraries(${TARGET_NAME}
PRIVATE
android
native_app_glue
)
# Export ANativeActivity_onCreate(),
# Refer to: https://github.com/android-ndk/ndk/issues/381.
set_target_properties(${TARGET_NAME}
PROPERTIES
LINK_FLAGS "-u ANativeActivity_onCreate"
)
#target_include_directories(${TARGET_NAME}
#PRIVATE
# ${ANDROID_NDK}/sources/android/cpufeatures
#)
source_group("Android" FILES ${ANDROID_SOURCE})
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_android_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_LINUX)
set(SOURCE
src/Linux/LinuxMain.cpp
)
set(INCLUDE
include/Linux/LinuxAppBase.hpp
)
function(add_linux_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_executable(${TARGET_NAME} ${SOURCE} ${INCLUDE} ${ASSETS})
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_linux_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_MACOS)
set(SOURCE
src/MacOS/MacOSAppBase.cpp
)
set(INCLUDE
include/MacOS/MacOSAppBase.hpp
)
function(add_macos_app TARGET_NAME SOURCE INCLUDE ASSETS)
get_target_property(NATIVE_APP_SOURCE_DIR Diligent-NativeAppBase SOURCE_DIR)
set(APPLE_SOURCE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/main.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/WindowController.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/AppDelegate.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/FullscreenWindow.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/GLView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MetalView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MVKView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewBase.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewController.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ModeSelectionViewController.mm
)
set(APPLE_INCLUDE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/WindowController.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/AppDelegate.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/FullscreenWindow.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/GLView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MetalView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/MVKView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewBase.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ViewController.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX/ModeSelectionViewController.h
)
set(APPLE_RESOURCES
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Base.lproj/Main.storyboard
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Images.xcassets/AppIcon.appiconset/dg.icns
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Images.xcassets/opengl-logo.png
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Images.xcassets/vulkan-logo.png
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Images.xcassets/metal-logo.png
)
set(APPLE_INFO_PLIST
${NATIVE_APP_SOURCE_DIR}/Apple/Data/OSX/Info.plist
)
set(APPLE_INCLUDE_DIRS
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/OSX
)
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${SOURCE} ${APPLE_SOURCE} ${INCLUDE} ${APPLE_INCLUDE} ${ASSETS} ${APPLE_RESOURCES})
string(REPLACE "_" "-" BUNDLE_NAME ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.diligentengine.samples.${BUNDLE_NAME}"
MACOSX_BUNDLE_INFO_PLIST "${APPLE_INFO_PLIST}"
RESOURCE "${APPLE_RESOURCES}"
)
source_group("MacOS" FILES ${APPLE_SOURCE})
source_group("MacOS" FILES ${APPLE_INCLUDE})
source_group("Resources" FILES ${APPLE_RESOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${APPLE_INCLUDE_DIRS})
find_package(OpenGL REQUIRED)
find_library(CORE_VIDEO CoreVideo)
if (NOT CORE_VIDEO)
message(FATAL_ERROR "CoreVideo is not found")
endif()
find_library(METAL_FRAMEWORK Metal)
if (NOT METAL_FRAMEWORK)
message(FATAL_ERROR "Metal framework is not found")
endif()
find_library(CORE_ANIMATION QuartzCore)
if (NOT CORE_ANIMATION)
message(FATAL_ERROR "QuartzCore (CoreAnimation) is not found")
endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${OPENGL_LIBRARY} ${CORE_VIDEO} ${METAL_FRAMEWORK} ${CORE_ANIMATION})
# Silence OpenGL deprecation warnings
target_compile_definitions(${TARGET_NAME} PUBLIC GL_SILENCE_DEPRECATION)
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_macos_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_IOS)
set(SOURCE
src/IOS/IOSAppBase.cpp
)
set(INCLUDE
include/IOS/IOSAppBase.hpp
)
function(add_ios_app TARGET_NAME SOURCE INCLUDE ASSETS)
get_target_property(NATIVE_APP_SOURCE_DIR Diligent-NativeAppBase SOURCE_DIR)
set(APPLE_SOURCE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/main.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/AppDelegate.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/BaseView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/EAGLView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/AppViewBase.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/ModeSelectionViewController.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/MetalView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/MVKView.mm
)
set(APPLE_INCLUDE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/AppDelegate.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/BaseView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/EAGLView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/AppViewBase.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/ModeSelectionViewController.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/MetalView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS/MVKView.h
)
set(APPLE_RESOURCES
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Base.lproj/Main.storyboard
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Base.lproj/LaunchScreen.xib
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Images.xcassets/AppIcon.appiconset/dg-icon.png
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Images.xcassets/opengles-logo.png
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Images.xcassets/vulkan-logo.png
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/Images.xcassets/metal-logo.png
)
set(APPLE_INFO_PLIST
${NATIVE_APP_SOURCE_DIR}/Apple/Data/iOS/info.plist
)
set(APPLE_INCLUDE_DIRS
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/iOS
)
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${SOURCE} ${APPLE_SOURCE} ${INCLUDE} ${APPLE_INCLUDE} ${ASSETS} ${APPLE_RESOURCES})
string(REPLACE "_" "-" BUNDLE_NAME ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.diligentengine.samples.${BUNDLE_NAME}"
MACOSX_BUNDLE_INFO_PLIST "${APPLE_INFO_PLIST}"
RESOURCE "${APPLE_RESOURCES}"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
# XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "Dev Team"
BUILD_RPATH "@executable_path"
)
source_group("iOS" FILES ${APPLE_SOURCE})
source_group("iOS" FILES ${APPLE_INCLUDE})
source_group("Resources" FILES ${APPLE_RESOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${APPLE_INCLUDE_DIRS})
find_library(OPENGLES OpenGLES)
if (NOT OPENGLES)
message(FATAL_ERROR "OpenGLES is not found")
endif()
find_library(UIKIT UIKit)
if (NOT UIKIT)
message(FATAL_ERROR "UIKIT is not found")
endif()
find_library(CORE_ANIMATION QuartzCore)
if (NOT CORE_ANIMATION)
message(FATAL_ERROR "QuartzCore (CoreAnimation) is not found")
endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${OPENGLES} ${UIKIT} ${CORE_ANIMATION})
# Silence OpenGLES deprecation warnings
target_compile_definitions(${TARGET_NAME} PUBLIC GLES_SILENCE_DEPRECATION)
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_ios_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_TVOS)
set(SOURCE
src/TVOS/TVOSAppBase.cpp
)
set(INCLUDE
include/TVOS/TVOSAppBase.hpp
)
function(add_tvos_app TARGET_NAME SOURCE INCLUDE ASSETS)
get_target_property(NATIVE_APP_SOURCE_DIR Diligent-NativeAppBase SOURCE_DIR)
set(APPLE_SOURCE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/main.m
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/AppDelegate.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MainUIView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MetalView.mm
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MetalViewController.mm
)
set(APPLE_INCLUDE
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/AppDelegate.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MainUIView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MetalView.h
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS/MetalViewController.h
)
set(APPLE_RESOURCES
${NATIVE_APP_SOURCE_DIR}/Apple/Data/tvOS/Base.lproj/Main.storyboard
)
set(APPLE_INFO_PLIST
${NATIVE_APP_SOURCE_DIR}/Apple/Data/tvOS/info.plist
)
set(APPLE_INCLUDE_DIRS
${NATIVE_APP_SOURCE_DIR}/Apple/Source/Classes/tvOS
)
add_executable(${TARGET_NAME} MACOSX_BUNDLE ${SOURCE} ${APPLE_SOURCE} ${INCLUDE} ${APPLE_INCLUDE} ${ASSETS} ${APPLE_RESOURCES})
string(REPLACE "_" "-" BUNDLE_NAME ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.diligentengine.samples.${BUNDLE_NAME}"
MACOSX_BUNDLE_INFO_PLIST "${APPLE_INFO_PLIST}"
RESOURCE "${APPLE_RESOURCES}"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
# XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "Dev Team"
BUILD_RPATH "@executable_path"
)
source_group("tvOS" FILES ${APPLE_SOURCE})
source_group("tvOS" FILES ${APPLE_INCLUDE})
source_group("Resources" FILES ${APPLE_RESOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${APPLE_INCLUDE_DIRS})
find_library(UIKIT UIKit)
if (NOT UIKIT)
message(FATAL_ERROR "UIKIT is not found")
endif()
find_library(CORE_ANIMATION QuartzCore)
if (NOT CORE_ANIMATION)
message(FATAL_ERROR "QuartzCore (CoreAnimation) is not found")
endif()
target_link_libraries(${TARGET_NAME} PRIVATE ${UIKIT} ${CORE_ANIMATION})
# Silence OpenGLES deprecation warnings (we don't use GLES, but still XCode produces errors)
target_compile_definitions(${TARGET_NAME} PUBLIC GLES_SILENCE_DEPRECATION)
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_tvos_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
elseif(PLATFORM_WEB)
set(SOURCE
src/Emscripten/EmscriptenAppBase.cpp
src/Emscripten/EmscriptenMain.cpp
)
set(INCLUDE
include/Emscripten/EmscriptenAppBase.hpp
)
function(add_emscripten_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_executable(${TARGET_NAME} ${SOURCE} ${INCLUDE} ${ASSETS})
# The initial amount of memory to use. Using more memory than this will cause us to expand the heap,
# which can be costly with typed arrays. If ALLOW_MEMORY_GROWTH is set, this initial amount of memory can
# increase later; if not, then it is the final and total amount of memory.
#target_link_options(${TARGET_NAME} PRIVATE "SHELL: -s INITIAL_MEMORY=32MB")
# If false, the app is aborted with an error if it tries to allocate more memory than INITIAL_MEMORY.
# If true, the memory arrays will grow at runtime, seamlessly and dynamically.
# Related: MEMORY_GROWTH_GEOMETRIC_STEP, MEMORY_GROWTH_GEOMETRIC_CAP, MEMORY_GROWTH_LINEAR_STEP
target_link_options(${TARGET_NAME} PRIVATE "SHELL: -s ALLOW_MEMORY_GROWTH=1")
# Default stack size is only 64 Kb
# https://emscripten.org/docs/tools_reference/settings_reference.html?highlight=environment#default-pthread-stack-size
target_link_options(${TARGET_NAME} PRIVATE "SHELL: -s STACK_SIZE=5MB")
# The default implementation of malloc/free (dlmalloc) uses a single global lock,
# which creates contention in multithreaded applications.
# Use mimalloc that scales a lot better.
target_link_options(${TARGET_NAME} PRIVATE "SHELL: -s MALLOC=mimalloc")
endfunction()
function(add_target_platform_app TARGET_NAME SOURCE INCLUDE ASSETS)
add_emscripten_app("${TARGET_NAME}" "${SOURCE}" "${INCLUDE}" "${ASSETS}")
endfunction()
else()
message(FATAL_ERROR "Unknown platform")
endif()
list(APPEND INCLUDE
include/AppBase.hpp
include/NativeAppBase.hpp
include/CommandLineParser.hpp
)
add_library(Diligent-NativeAppBase STATIC ${SOURCE} ${INCLUDE})
set_common_target_properties(Diligent-NativeAppBase)
if(MSVC)
target_compile_options(Diligent-NativeAppBase PRIVATE -DUNICODE)
if(PLATFORM_UNIVERSAL_WINDOWS)
# Disable w4189: local variable is initialized but not referenced
# Disable w4063: case is not a valid value for switch of enum
# Consume the windows runtime extensions (/ZW)
target_compile_options(Diligent-NativeAppBase INTERFACE /wd4189 /wd4063)
endif()
endif()
target_include_directories(Diligent-NativeAppBase
PUBLIC
include
)
target_link_libraries(Diligent-NativeAppBase
PRIVATE
Diligent-BuildSettings
Diligent-Common
)
if(PLATFORM_WIN32)
target_include_directories(Diligent-NativeAppBase
PUBLIC
include/Win32
)
elseif(PLATFORM_UNIVERSAL_WINDOWS)
target_include_directories(Diligent-NativeAppBase
PUBLIC
include/UWP
src/UWP
)
elseif(PLATFORM_ANDROID)
target_link_libraries(Diligent-NativeAppBase PUBLIC NDKHelper native_app_glue PRIVATE android)
target_include_directories(Diligent-NativeAppBase
PUBLIC
include/Android
)
elseif(PLATFORM_LINUX)
find_package(X11 REQUIRED)
target_link_libraries(Diligent-NativeAppBase
PRIVATE
X11::X11
)
if(GL_SUPPORTED)
find_package(OpenGL REQUIRED)
target_link_libraries(Diligent-NativeAppBase
PRIVATE
OpenGL::GL
OpenGL::GLX
)
endif()
target_include_directories(Diligent-NativeAppBase
PUBLIC
include/Linux
)
if(VULKAN_SUPPORTED)
find_library(XCB_LIBRARY xcb)
target_link_libraries(Diligent-NativeAppBase
PRIVATE
${XCB_LIBRARY}
)
endif()
elseif(PLATFORM_MACOS)
target_include_directories(Diligent-NativeAppBase PUBLIC
src/MacOS
include/MacOS
)
elseif(PLATFORM_IOS)
target_include_directories(Diligent-NativeAppBase PUBLIC
include/IOS
)
elseif(PLATFORM_TVOS)
target_include_directories(Diligent-NativeAppBase PUBLIC
include/TVOS
)
elseif(PLATFORM_WEB)
target_include_directories(Diligent-NativeAppBase PUBLIC
include/Emscripten
)
endif()
source_group("src" FILES ${SOURCE})
source_group("include" FILES ${INCLUDE})
set_target_properties(Diligent-NativeAppBase PROPERTIES
FOLDER DiligentTools
)