Skip to content

Commit c27ac04

Browse files
Fix BRN build sourcetree (#1532)
related to BabylonJS/BabylonReactNative#665 Some dependencies are fetched only for the platform being built. `BABYLON_NATIVE_BUILD_SOURCETREE` variable has been added to allow fetching independently of active platform. --------- Co-authored-by: Drew Fillebrown <[email protected]>
1 parent b9a1f2b commit c27ac04

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include(FetchContent)
1111
# --------------------------------------------------
1212
FetchContent_Declare(AndroidExtensions
1313
GIT_REPOSITORY https://github.com/BabylonJS/AndroidExtensions.git
14-
GIT_TAG 7d88a601fda9892791e7b4e994e375e049615688)
14+
GIT_TAG 66520bff9b57030b67894a4934d18ad7e161ba6f)
1515
FetchContent_Declare(arcana.cpp
1616
GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git
1717
GIT_TAG 1a8a5d6e95413ed14b38a6ac9419048f9a9c8009)
@@ -48,18 +48,27 @@ FetchContent_Declare(libwebp
4848

4949
FetchContent_MakeAvailable(CMakeExtensions)
5050

51-
if(VISIONOS)
51+
# BABYLON_NATIVE_BUILD_SOURCETREE flag is used by BabylonReactNative NPM build process.
52+
# CMake script is run twice. At package creation, BABYLON_NATIVE_BUILD_SOURCETREE is ON
53+
# which makes all dependencies to be fetched and packaged.
54+
# At build time, cmake is run again on BabylonNative root but FETCHCONTENT_FULLY_DISCONNECTED is ON
55+
# and FetchContent_MakeAvailable_With_Message will use provided local folder provided to cmake command line
56+
# like '-DFETCHCONTENT_SOURCE_DIR_BGFX.CMAKE=../shared/Babylon/....'
57+
58+
if(VISIONOS OR IOS OR BABYLON_NATIVE_BUILD_SOURCETREE)
5259
FetchContent_MakeAvailable_With_Message(ios-cmake)
53-
set(CMAKE_TOOLCHAIN_FILE "${ios-cmake_SOURCE_DIR}/ios.toolchain.cmake" CACHE PATH "")
60+
if(NOT BABYLON_NATIVE_BUILD_SOURCETREE)
61+
set(CMAKE_TOOLCHAIN_FILE "${ios-cmake_SOURCE_DIR}/ios.toolchain.cmake" CACHE PATH "")
62+
endif()
63+
set(ENABLE_ARC OFF CACHE STRING "Enables or disables ARC support.")
64+
endif()
65+
66+
if(VISIONOS)
5467
set(PLATFORM "VISIONOSCOMBINED" CACHE STRING "")
5568
set(DEPLOYMENT_TARGET "1.0" CACHE STRING "")
56-
set(ENABLE_ARC OFF CACHE STRING "Enables or disables ARC support.")
5769
elseif(IOS)
58-
FetchContent_MakeAvailable_With_Message(ios-cmake)
59-
set(CMAKE_TOOLCHAIN_FILE "${ios-cmake_SOURCE_DIR}/ios.toolchain.cmake" CACHE PATH "")
6070
set(PLATFORM "OS64COMBINED" CACHE STRING "")
6171
set(DEPLOYMENT_TARGET "13" CACHE STRING "")
62-
set(ENABLE_ARC OFF CACHE STRING "Enables or disables ARC support.")
6372
endif()
6473

6574
project(BabylonNative)

Dependencies/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
33
# --------------------------------------------------
44
# AndroidExtensions
55
# --------------------------------------------------
6-
if(ANDROID)
6+
if(ANDROID OR BABYLON_NATIVE_BUILD_SOURCETREE)
77
FetchContent_MakeAvailable_With_Message(AndroidExtensions)
88
endif()
99

@@ -15,7 +15,7 @@ FetchContent_MakeAvailable_With_Message(arcana.cpp)
1515
# --------------------------------------------------
1616
# arcore-android-sdk
1717
# --------------------------------------------------
18-
if(ANDROID)
18+
if(ANDROID OR BABYLON_NATIVE_BUILD_SOURCETREE)
1919
FetchContent_MakeAvailable_With_Message(arcore-android-sdk)
2020
endif()
2121

@@ -192,7 +192,7 @@ endif()
192192
# xr
193193
# --------------------------------------------------
194194
# Currently supported on Android via ARCore, and iOS via ARKit.
195-
if(BABYLON_NATIVE_PLUGIN_NATIVEXR AND (ANDROID OR IOS))
195+
if((BABYLON_NATIVE_PLUGIN_NATIVEXR AND (ANDROID OR IOS)) OR BABYLON_NATIVE_BUILD_SOURCETREE)
196196
add_subdirectory(xr)
197197
set_property(TARGET xr PROPERTY FOLDER Dependencies/xr)
198198
warnings_as_errors(xr)

Dependencies/xr/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (ANDROID)
3333
set(SOURCES ${SOURCES}
3434
"Source/ARCore/Include/IXrContextARCore.h"
3535
"Source/ARCore/XR.cpp")
36-
elseif (IOS)
36+
elseif(IOS OR BABYLON_NATIVE_BUILD_SOURCETREE)
3737
set(SOURCES ${SOURCES}
3838
"Source/ARKit/Include/IXrContextARKit.h"
3939
"Source/ARKit/XR.mm")

0 commit comments

Comments
 (0)