Building Cesium-Unreal for VisionOS

Hi @dagillespie,

Well, I’m not really sure. The KTX build is very, uh, special, so it’s not unusual for it to behave badly. It’s hard to say what exactly is going wrong, though. Taking a quick look at its cmake build (KTX-Software/CMakeLists.txt at v4.3.2 · KhronosGroup/KTX-Software · GitHub), there’s a lot of if (IOS) type stuff going on. It’s possible that needs to be expanded to include visionOS. That is, assuming you’re telling cmake it’s a visionOS build, which I think you are, right?

It’d probably be helpful to see your triplet and toolchain files.

Hi @Kevin_Ring,
Many thanks - Yes I am trying to get it to target VisionOS yes. I’m currently making the current patches to the following files:

updates to detect-vcpkg-cmake (in order to download the iOS source code to build for VisionOS:

...
elseif(IOS)
    set(DETECTED_VCPKG_TRIPLET "arm64-ios")
elseif (CMAKE_SYSTEM_NAME STREQUAL "visionOS")
    message(STATUS "DETECT-VCPKG-TRIPLET.Cmake: Using iOS source for Vision OS builds")
    set(DETECTED_VCPKG_TRIPLET "arm64-ios")
elseif(WINDOWS_STORE)
...

main buildScript which overrides the toolchain file for EZVCPKG:

...
#set custom toolchain file for vcpkg
export VCPKG_CHAINLOAD_TOOLCHAIN_FILE=$BUILD_ROOT/extern/unreal-visionos-toolchain.cmake
export EZVCPKG_LOG_LEVEL=DEBUG
#log value of VCPKG
echo "VCPKG_CHAINLOAD_TOOLCHAIN_FILE set to: ${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
cmake -B build-visionos -S . -GXcode \
  -DCMAKE_TOOLCHAIN_FILE="unreal-visionos-toolchain.cmake" \
  -DCMAKE_BUILD_TYPE=Release

unreal-visionos-toolchain.cmake:

#VisonOS Settings
set(GENERATOR Xcode)
set(CMAKE_GENERATOR Xcode)
set(CMAKE_SYSTEM_NAME visionOS)
set(CMAKE_OSX_SYSROOT xros)
set(CMAKE_OSX_ARCHITECTURES arm64)
set(CMAKE_SYSTEM_PROCESSOR arm64)
set(CMAKE_OSX_DEPLOYMENT_TARGET 2.1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)

I’m not directly touching the KTX CMake from KTX’s repo, as I was assuming that KTX was inheriting the properties directly from VisionOS triplet for build - however I appreciate that perhaps KTX itself needs adapting in some way for this target. It’s a little opaque (at least for me) as to how KTX CMake is being called and where I could intervene in the build process to make changes.

In particular, where the only thing I can seem to find for KTX is the following within vcpkg-overlays which appears to be applying patches to the KTX CMake, however I can’t find where the repo is being cloned to - all that there appears to be is a variable called OUTPUT_PATH in the portfile.cmake where it is not clear where this location is being set. If I had that, I could test a manual patch of the cmake file to add in VisionOS:

Well, as usual, I don’t know the answer, but maybe I can offer a small hint…

You’re setting an environment variable called VCPKG_CHAINLOAD_TOOLCHAIN_FILE. But as far as I can tell, vcpkg doesn’t ever look at such an environment variable. You need to specify that in the triplet file instead. You can make the triplet file pick up the value from the environment variable like this:

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "$ENV{VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")

But you’ll also need to make sure VCPKG_CHAINLOAD_TOOLCHAIN_FILE is set in VCPKG_ENV_PASSTHROUGH or else the above won’t work. See extern/vcpkg-overlays/triplets/shared/common.cmake.