forked from BabylonJS/BabylonNative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
119 lines (103 loc) · 4.31 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
# cmake 3.18+ to have the ARCHIVE_EXTRACT sub-command for files
cmake_minimum_required(VERSION 3.18)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(BabylonNative)
# --------------------------------------------------
# Options
# --------------------------------------------------
option(BABYLON_NATIVE_BUILD_APPS "Build Babylon Native apps." ON)
option(BABYLON_NATIVE_INSTALL "Include the install target." ON)
## Core
option(BABYLON_NATIVE_CORE_JSRUNTIME "Include Babylon Native Core JsRuntime" ON)
option(BABYLON_NATIVE_CORE_APPRUNTIME "Include Babylon Native Core AppRuntime" ON)
option(BABYLON_NATIVE_CORE_SCRIPTLOADER "Include Babylon Native Core ScriptLoader" ON)
option(BABYLON_NATIVE_CORE_GRAPHICS "Include Babylon Native Core Graphics" ON)
## Plugins
option(BABYLON_NATIVE_PLUGIN_CHROMEDEVTOOLS "Include Babylon Native Plugin ChromeDevTools." ON)
option(BABYLON_NATIVE_PLUGIN_EXTERNALTEXTURE "Include Babylon Native Plugin ExternalTexture." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVECAMERA "Include Babylon Native Plugin NativeCamera." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVECAPTURE "Include Babylon Native Plugin NativeCapture." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeInput." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEOPTIMIZATIONS "Include Babylon Native Plugin NativeOptimizations." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVETRACING "Include Babylon Native Plugin NativeTracing." ON)
option(BABYLON_NATIVE_PLUGIN_TESTUTILS "Include Babylon Native Plugin TestUtils." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEXR "Include Babylon Native Plugin XR." ON)
## Polyfills
option(BABYLON_NATIVE_POLYFILL_CONSOLE "Include Babylon Native Polyfill Console." ON)
option(BABYLON_NATIVE_POLYFILL_WINDOW "Include Babylon Native Polyfill Window." ON)
option(BABYLON_NATIVE_POLYFILL_XMLHTTPREQUEST "Include Babylon Native Polyfill XMLHttpRequest." ON)
option(BABYLON_NATIVE_POLYFILL_CANVAS "Include Babylon Native Polyfill Canvas." ON)
# --------------------------------------------------
if(APPLE)
# without this option on azure pipelines, there is a mismatch with math.h giving a lot of undefined functions on macOS.
# only enabled for Apple as there is no issue for UWP/WIN32
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
endif()
# Setting Platform
if(ANDROID)
set(BABYLON_NATIVE_PLATFORM "Android")
elseif(IOS)
set(BABYLON_NATIVE_PLATFORM "iOS")
elseif(APPLE)
set(BABYLON_NATIVE_PLATFORM "macOS")
elseif(WINDOWS_STORE)
set(BABYLON_NATIVE_PLATFORM "UWP")
elseif(WIN32)
set(BABYLON_NATIVE_PLATFORM "Win32")
elseif(UNIX)
set(BABYLON_NATIVE_PLATFORM "Unix")
else()
message(FATAL_ERROR "Unrecognized platform: ${CMAKE_SYSTEM_NAME}")
endif()
# Setting Graphics API
if(APPLE)
set(GRAPHICS_API Metal)
elseif(UNIX)
if(NOT GRAPHICS_API)
set(GRAPHICS_API OpenGL)
else()
if(NOT GRAPHICS_API STREQUAL Vulkan AND NOT GRAPHICS_API STREQUAL OpenGL)
message(FATAL_ERROR "Unrecognized/Unsupported render API: ${GRAPHICS_API}")
endif()
endif()
elseif(WIN32)
if(NOT GRAPHICS_API)
set(GRAPHICS_API D3D11)
else()
if(NOT GRAPHICS_API STREQUAL Vulkan AND NOT GRAPHICS_API STREQUAL D3D11 AND NOT GRAPHICS_API STREQUAL D3D12)
message(FATAL_ERROR "Unrecognized/Unsupported render API: ${GRAPHICS_API}")
endif()
endif()
endif()
if(APPLE)
set(BABYLON_NATIVE_PLATFORM_IMPL_EXT "mm")
else()
set(BABYLON_NATIVE_PLATFORM_IMPL_EXT "cpp")
endif()
if(UNIX AND NOT APPLE AND NOT ANDROID)
# Use GLVND libraries for EGL support in bgfx
set(OpenGL_GL_PREFERENCE GLVND)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# __cplusplus value is not in sync with language version used. MVSC needs this flag to update it accordingly
# https://gitlab.kitware.com/cmake/cmake/-/issues/18837
if (MSVC)
add_compile_options(/Zc:__cplusplus)
endif()
add_subdirectory(Dependencies)
add_subdirectory(Core)
add_subdirectory(Plugins)
add_subdirectory(Polyfills)
if(DEFINED EXTENSIONS_DIRS)
foreach(extensionDir IN LISTS EXTENSIONS_DIRS)
add_subdirectory(${extensionDir} "Extensions")
endforeach()
endif()
if(BABYLON_NATIVE_BUILD_APPS)
add_subdirectory(Apps)
endif()
if(BABYLON_NATIVE_INSTALL)
include(Install/Install.cmake)
endif()