ios-cmake
ios-cmake copied to clipboard
Add support for visionOS
Feature request Please add support for the xrOS platform and simulator.
Please have a look at the PR @ #175 :)
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.
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.
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.
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..
Remove APPLE_TARGET_TRIPLE_INT for successful compile
+1
Any progress on this ticket?
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"
Okay looks like CMake are on the case: https://gitlab.kitware.com/cmake/cmake/-/issues/25188
Fix in Cmake 3.28.4
https://github.com/Kitware/CMake/commit/361e5fd441e2282bc1415c31a7bcf4901941ae79
Merged in Cmake 3.29.0 just released today!
Yep, the tests added to the toolchain does indeed now work for the xrOS (visionOS) platform. Closing this issue.