ios-cmake icon indicating copy to clipboard operation
ios-cmake copied to clipboard

Add support for visionOS

Open knight556 opened this issue 2 years ago • 11 comments

Feature request Please add support for the xrOS platform and simulator.

knight556 avatar Jun 25 '23 21:06 knight556

Please have a look at the PR @ #175 :)

leetal avatar Jun 25 '23 21:06 leetal

clang: error: cannot specify '-mtargetos=xros1.0' along with '-target arm64-apple-xros1.0'

The latest toolchain file doesn't work for me. I'm using a nightly version of CMake (cmake-3.27.20230807) with the PR supportting visionOS merged.

floppyhammer avatar Aug 08 '23 07:08 floppyhammer

Okay, I found a solution. You just cannot specify both of -mtargetos (which is specified in Apple-Clang.cmake) and -target. Commenting the lines to set APPLE_TARGET_TRIPLE_INT around here https://github.com/leetal/ios-cmake/blob/b0e8b29da5025cc728b442b3f6b88e1f923b885b/ios.toolchain.cmake#L500C1-L507C10 works for me.

floppyhammer avatar Aug 08 '23 08:08 floppyhammer

It turned out the above-mentioned solution doesn't work. You can get the library to compile this way, but you cannot link it with other libraries built with Xcode.

error: binaries with multiple platforms are not supported

It's probably due to the wrong build target given by CMake.

I ended up leaving the toolchain file and modifying Apple-Clang.cmake instead.

  elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XROS")
  #  set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtargetos=xros")
  elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/XRSimulator")
  #  set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtargetos=xros")

Now it links without a problem.

floppyhammer avatar Aug 10 '23 10:08 floppyhammer

The "poor-mans-choice workaround" could be to actually filter any -mtargetos=xros from the C[XX]_FLAGS prior to building (if building visionOS) with the toolchain. But then we'd be "breaking" (read fix) the upstream features which i really don't want either.. Hard one to crack..

leetal avatar Aug 10 '23 21:08 leetal

Remove APPLE_TARGET_TRIPLE_INT for successful compile

danoli3 avatar Feb 07 '24 23:02 danoli3

+1

paulocoutinhox avatar Feb 08 '24 19:02 paulocoutinhox

Any progress on this ticket?

knight556 avatar Mar 08 '24 02:03 knight556

Yes this actually is still a problem when linking the XROS Sim and XROS causing issues.

Problem still occurring. Looking into

  Run Build Command(s): /opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_cf39d/fast
    /Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/cmTC_cf39d.dir/build.make CMakeFiles/cmTC_cf39d.dir/build
    Building C object CMakeFiles/cmTC_cf39d.dir/testCCompiler.c.o
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang   --target=-apple-xros1.0   -fvisibility=hidden -fvisibility-inlines-hidden   -std=gnu17 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.0.sdk -mtargetos=xros1.0 -fPIC -MD -MT CMakeFiles/cmTC_cf39d.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_cf39d.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_cf39d.dir/testCCompiler.c.o -c /Users/~/SOURCE/openFrameworksmacOS/scripts/apothecary/apothecary/build/zlib/build_xros_VISIONOS/CMakeFiles/CMakeScratch/TryCompile-BLvmqO/testCCompiler.c
    clang: error: cannot specify '-mtargetos=xros1.0' along with '--target=-apple-xros1.0'
    make[1]: *** [CMakeFiles/cmTC_cf39d.dir/testCCompiler.c.o] Error 1
    make: *** [cmTC_cf39d/fast] Error 
    ```
    
 Yeah essentially need to remove the "-mtargetos=xros1.0" 

danoli3 avatar Mar 08 '24 06:03 danoli3

Okay looks like CMake are on the case: https://gitlab.kitware.com/cmake/cmake/-/issues/25188

Fix in Cmake 3.28.4

danoli3 avatar Mar 08 '24 09:03 danoli3

https://github.com/Kitware/CMake/commit/361e5fd441e2282bc1415c31a7bcf4901941ae79

Merged in Cmake 3.29.0 just released today!

danoli3 avatar Mar 22 '24 03:03 danoli3

Yep, the tests added to the toolchain does indeed now work for the xrOS (visionOS) platform. Closing this issue.

leetal avatar Jul 18 '24 14:07 leetal