CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
358 stars 83 forks source link

WIP Added Vision Pro build support #502

Open handzlikchris opened 2 months ago

handzlikchris commented 2 months ago

Added Vision Pro build support, this is done by:

Still work in progress but should be good starting place for anyone looking to use Cesium for Unity on Vision Pro / Polyspatial.

Approach taken here contains some workarounds - happy to continue on this one but would need some guidance.

1) Cesium native is built using IOS config and XCode project is later re-targetted to xros, ideally we'd have separate xros toolchain for cmake, eg extern/xros-toolchain.cmake when I tried to build that it'd fail when resolving triplets

*** The output from the command was:
Computing installation plan...
The following packages will be built and installed:
    asyncplusplus:arm64-ios-unity@1.1#2 -- /Volumes/External/src/cesium-unity-samples-vp/Packages/com.cesium.unity/native~/vcpkg/ports/asyncplusplus
  * vcpkg-cmake:arm64-osx@2024-04-23
  * vcpkg-cmake-config:arm64-osx@2024-05-23
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet arm64-osx...
Compiler found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
Unable to determine toolchain use for arm64-ios-unity with with CMAKE_SYSTEM_NAME visionOS. Did you mean to use VCPKG_CHAINLOAD_TOOLCHAIN_FILE?
note: updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.

Could resolve that properly to build for VisionOS from start.

2) Needed to hardcode some generated libs to be exlcuded from build

"libjpeg.a",
"libwebp.a"

As they fail to compile (duplicated symbols) - not 100% sure if that exclusion will cause issues.

Also looks like native project for this PR installs into Plugins folder quite a lot of libraries that I've not seen built in other forum threads, notably 86 libs build for libabsl_XXX.a eg libabsl_bad_any_cast_impl.a, libabsl_string_view.a, libabsl_throw_delegate.a

eirikwah commented 2 months ago

Thank you for starting a PR for this. I don't have time to help right now (AVP-support in my project does not have high priority right now), however I would like to add this information:

A complete solution (not verified by me yet) is mentioned here: https://github.com/CesiumGS/cesium-unity/issues/409#issuecomment-2325620383 (pointing to https://github.com/HoloLabInc/ProjectSpirare-for-Unity/tree/main/unity/SpirareBrowser-visionOS-3DMaps#edit-cesium-for-unity and https://github.com/HoloLabInc/ProjectSpirare-for-Unity/blob/main/unity/SpirareBrowser-visionOS-3DMaps/Assets/App/Editor/CesiumPostProcessBuildForVisionOS.cs)

Here are some other links that describes some of the problems and some possible solutions:

kring commented 2 months ago

Thanks for the PR @handzlikchris!

Unable to determine toolchain use for arm64-ios-unity with with CMAKE_SYSTEM_NAME visionOS. Did you mean to use VCPKG_CHAINLOAD_TOOLCHAIN_FILE?

Hmm it kind of seems like vcpkg doesn't understand visionOS as a system name. Information on this seems to be really sparse in my attempts to search so far. Worst case, it'll be necessary to define a custom toolchain.

A stupid question first, though... is visionOS really different from iOS? What I mean is, for fairly low-level code like cesium-native and its dependencies, is it possible to target a "least common denominator" of iOS and visionOS such that we don't need separate binaries for each? Or are they really such different operating systems?

handzlikchris commented 2 months ago

@kring That's good question. To be honest I don't know how different VisionOS is from IOS. I don't have much experience with cmake, though that it may be a low-hanging fruit to change target to VisionOS for someone with more knowledge there.

If not - it may well be that building for IOS is good enough

handzlikchris commented 2 months ago

Thank you for starting a PR for this. I don't have time to help right now (AVP-support in my project does not have high priority right now), however I would like to add this information:

A complete solution (not verified by me yet) is mentioned here: #409 (comment) (pointing to https://github.com/HoloLabInc/ProjectSpirare-for-Unity/tree/main/unity/SpirareBrowser-visionOS-3DMaps#edit-cesium-for-unity and https://github.com/HoloLabInc/ProjectSpirare-for-Unity/blob/main/unity/SpirareBrowser-visionOS-3DMaps/Assets/App/Editor/CesiumPostProcessBuildForVisionOS.cs)

Here are some other links that describes some of the problems and some possible solutions:

That's great find, thanks - I'll check it out