cmake-conan
cmake-conan copied to clipboard
conan_cmake_autodetect fails on clang 12 cross-build from Macos:x86_64 to iOS:armv8
I am trying to build with clang 12 for iOS:armv8 on a x86_64 mac but conan_cmake_autodetect throws the following error:
In file included from <stdin>:1:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:504:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:175:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:641:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:60:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string.h:60:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/string.h:61:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/_types.h:27:
In file included from /Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/sys/_types.h:32:
/Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/include/sys/cdefs.h:816:2: error: Unsupported architecture
#error Unsupported architecture
From what I could see this is caused by the following command:
/Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -x c++ --sysroot=/Applications/Xcode_12.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk -Wall;-Wextra;-Werror -E -dM -
which is called here: https://github.com/conan-io/cmake-conan/blob/1ed947da9c0207b070c7967af1c60da636039c33/conan.cmake#L359
The same cmake file works perfectly on Windows, Linux and for MacOS builds. Just this cross-build causes an issue.
Hi @MuhKuh7, Could you provide a minimal reproducible example so we can check?
@czoido. I hope this helps
conan create . test/1.0.0@ -tf=.conan/test_package -pr=.conan/profiles/ios-clang-12-armv8
@czoido, were you able to reproduce the issue with the provided example?
Problem still exists with 0.18.1 and XCode 13.1/clang 13
@czoido Any update on this one? I have the same issue with the given profile :
[settings]
arch=armv8
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.cppstd=14
os=iOS
os.version=11.0
os_build=Macos
Hi @axoloto,
If you want to cross-compile that profile with arch_build and os_build won't work in cmake-conan.
I would recommend you to skip the autodetect step and explicitly pass the profiles for build and host context in the conan_cmake_install step. Please check the con docs about the new model for cross-compile since 1.24 here: https://docs.conan.io/en/latest/systems_cross_building/cross_building.html#conan-v1-24-and-newer and also more info for the build and host profiles: https://docs.conan.io/en/latest/reference/profiles.html#build-profiles-and-host-profiles
Also, this part of the tutorial for the new Conan 2.0 may be useful to get an idea of the cross-build model in conan, but be aware that is based in Conan 2.0: https://docs.conan.io/en/2.0-alpha/tutorial/consuming_packages/cross_building_with_conan.html
Hope this helps!
Thanks a lot for your quick reply @czoido! It definitely helped me understanding it better!