forked from BabylonJS/BabylonNative
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
192 lines (165 loc) · 7.48 KB
/
Copy pathCMakeLists.txt
File metadata and controls
192 lines (165 loc) · 7.48 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
cmake_minimum_required(VERSION 3.21)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
include(FetchContent)
# --------------------------------------------------
# Declarations
# --------------------------------------------------
FetchContent_Declare(AndroidExtensions
GIT_REPOSITORY https://github.com/BabylonJS/AndroidExtensions.git
GIT_TAG 66520bff9b57030b67894a4934d18ad7e161ba6f)
FetchContent_Declare(arcana.cpp
GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git
GIT_TAG 1a8a5d6e95413ed14b38a6ac9419048f9a9c8009)
FetchContent_Declare(arcore-android-sdk
GIT_REPOSITORY https://github.com/google-ar/arcore-android-sdk.git
GIT_TAG 98cb803de5482fb2b36effe8be3b5a0d3b726976)
FetchContent_Declare(base-n
GIT_REPOSITORY https://github.com/azawadzki/base-n.git
GIT_TAG 7573e77c0b9b0e8a5fb63d96dbde212c921993b4)
FetchContent_Declare(bgfx.cmake
GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git
GIT_TAG ed8e11f781024120980cdbbc5871cb2ce2f63423)
FetchContent_Declare(CMakeExtensions
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git
GIT_TAG ea28b7689530bfdc4905806f27ecf7e8ed4b5419)
FetchContent_Declare(glslang
GIT_REPOSITORY https://github.com/BabylonJS/glslang.git
GIT_TAG 6388a301b23edf0ae6a9342d46efa9cb21f05d9b)
FetchContent_Declare(googletest
URL "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz")
FetchContent_Declare(ios-cmake
GIT_REPOSITORY https://github.com/leetal/ios-cmake.git
GIT_TAG 4.5.0)
FetchContent_Declare(JsRuntimeHost
GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git
GIT_TAG ef57990dc5533990b2bb194978a12f8c8d83565c)
FetchContent_Declare(SPIRV-Cross
GIT_REPOSITORY https://github.com/BabylonJS/SPIRV-Cross.git
GIT_TAG 6abfcf066d171e9ade7604d91381ebebe4209edc)
FetchContent_Declare(libwebp
GIT_REPOSITORY https://github.com/webmproject/libwebp.git
GIT_TAG 57e324e2eb99be46df46d77b65705e34a7ae616c)
# --------------------------------------------------
FetchContent_MakeAvailable(CMakeExtensions)
# BABYLON_NATIVE_BUILD_SOURCETREE flag is used by BabylonReactNative NPM build process.
# CMake script is run twice. At package creation, BABYLON_NATIVE_BUILD_SOURCETREE is ON
# which makes all dependencies to be fetched and packaged.
# At build time, cmake is run again on BabylonNative root but FETCHCONTENT_FULLY_DISCONNECTED is ON
# and FetchContent_MakeAvailable_With_Message will use provided local folder provided to cmake command line
# like '-DFETCHCONTENT_SOURCE_DIR_BGFX.CMAKE=../shared/Babylon/....'
if(VISIONOS OR IOS OR BABYLON_NATIVE_BUILD_SOURCETREE)
FetchContent_MakeAvailable_With_Message(ios-cmake)
if(NOT BABYLON_NATIVE_BUILD_SOURCETREE)
set(CMAKE_TOOLCHAIN_FILE "${ios-cmake_SOURCE_DIR}/ios.toolchain.cmake" CACHE PATH "")
endif()
set(ENABLE_ARC OFF CACHE STRING "Enables or disables ARC support.")
endif()
if(VISIONOS)
set(PLATFORM "VISIONOSCOMBINED" CACHE STRING "")
set(DEPLOYMENT_TARGET "1.0" CACHE STRING "")
elseif(IOS)
set(PLATFORM "OS64COMBINED" CACHE STRING "")
set(DEPLOYMENT_TARGET "13" CACHE STRING "")
endif()
project(BabylonNative)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# --------------------------------------------------
# Options
# --------------------------------------------------
# General
option(BABYLON_NATIVE_BUILD_APPS "Build Babylon Native apps." ${PROJECT_IS_TOP_LEVEL})
option(BABYLON_NATIVE_INSTALL "Include the install target." ${PROJECT_IS_TOP_LEVEL})
option(BABYLON_DEBUG_TRACE "Enable debug trace." OFF)
# WARNING: This is experimental. Only use it if you can ensure that your application will properly handle thread affinity.
option(BABYLON_NATIVE_CHECK_THREAD_AFFINITY "Checks thread safety in the graphics device calls. It can be removed if hosting application ensures thread coherence." ON)
# Plugins
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_NATIVEENCODING "Include Babylon Native Plugin NativeEncoding." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON)
option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP "Include Babylon Native Plugin NativeEngine - WebP." 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_NATIVEXR "Include Babylon Native Plugin XR." ON)
option(BABYLON_NATIVE_PLUGIN_TESTUTILS "Include Babylon Native Plugin TestUtils." ON)
# Polyfills
option(BABYLON_NATIVE_POLYFILL_WINDOW "Include Babylon Native Polyfill Window." ON)
option(BABYLON_NATIVE_POLYFILL_CANVAS "Include Babylon Native Polyfill Canvas." ON)
# --------------------------------------------------
if(ANDROID)
set(BABYLON_NATIVE_PLATFORM "Android")
elseif(IOS)
set(BABYLON_NATIVE_PLATFORM "iOS")
elseif (VISIONOS)
set(BABYLON_NATIVE_PLATFORM "visionOS")
elseif(APPLE)
set(BABYLON_NATIVE_PLATFORM "macOS")
elseif(WINDOWS_STORE)
set(BABYLON_NATIVE_PLATFORM "WinRT")
elseif(WIN32)
set(BABYLON_NATIVE_PLATFORM "Win32")
elseif(UNIX)
set(BABYLON_NATIVE_PLATFORM "Unix")
else()
message(FATAL_ERROR "Unrecognized platform: ${CMAKE_SYSTEM_NAME}")
endif()
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(MSVC)
# __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
add_compile_options(/Zc:__cplusplus)
# https://devblogs.microsoft.com/cppblog/announcing-full-support-for-a-c-c-conformant-preprocessor-in-msvc/
add_compile_options(/Zc:preprocessor)
# default to /W3
add_compile_options(/W3)
endif()
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 Windows.
set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
# Create scheme for installation and other targets
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
endif()
if(BABYLON_DEBUG_TRACE)
add_compile_definitions(BABYLON_DEBUG_TRACE)
endif()
add_subdirectory(Dependencies)
add_subdirectory(Core)
add_subdirectory(Plugins)
add_subdirectory(Polyfills)
if(BABYLON_NATIVE_BUILD_APPS)
add_subdirectory(Apps)
endif()
# no install for glslang compiled for shaderc
if(BABYLON_NATIVE_INSTALL AND NOT BGFX_BUILD_TOOLS)
include(Install/Install.cmake)
endif()