![]() Save yet another version to just "amework". What I've done in the past is save one output to "x86_64/amework" and the other architecture to "arm64/amework". I'm not sure what you mean about "copying the output of xcodebuild". Now it works great and builds on all platforms, even in Xcode Cloud. One of my most important projects recently switched to cmake and that was the impetus I needed to set VERBOSE=1 and convert everything from automake, cmake, jam, ninja, and gn to Xcode. I don't even use the above build settings anymore. Otherwise, aside from being 8 hours too slow, I don't necessarily think you are doing anything wrong. IOS_PLATFORM=OS (As opposed to SIMULATOR, again, only for iphoneos builds) Here are the custom configuration options I specify in my code:ĬMAKE_INSTALL_PREFIX (You probably don't need this one)ĬMAKE_C_COMPILER (Set to /path/to/Xcode/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)ĬMAKE_AR (Set to /path/to/Xcode/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar)ĬMAKE_LINKER (Set to /path/to/Xcode/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld)ĬMAKE_TOOLCHAIN_FILE (Set to the iOS.cmake file mentioned above, but only for iphoneos builds). There is a custom config script floating around that is designed specifically for iOS. Getting cmake to generate iOS code is more difficult. I haven't encountered any cross platform incompatibilities on the several cmake-based projects I use. I'm afraid the most likely explanation is that your build scripts need significant changes. You can wrap the whole thing into a script and easily do the lipo first and then sign the universal app. I don't think you need to sign before doing lipo. I'd never heard of vcpkg before you mentioned it. Note if you set the SDKROOT environment variable, it is not necessary to add "-sysroot $SDKROOT" and "-isysroot $SDKROOT" to CFLAGS and CXXFLAGS.ĭo that for each (x86_64 and arm64) then use lipo to make universal binaries.Įdit: Oh and, with CMake, never set the "-target" flag in LDFLAGS, only in CFLAGS/CXXFLAGS, it won't like that. The important Clang compiler flags for cross-compiling are: -target -sysroot and -isysroot.įor CMake specifically, the relevant variables for cross-compiling are: CMAKE_C_COMPILER_TARGET CMAKE_CXX_COMPILER_TARGET CMAKE_SYSTEM_PROCESSOR and CMAKE_SYSTEM_NAME.įor example, to build for x86_64 on an M1 Mac (arm64): export TARGET="x86_64-apple-darwin"Įxport CXXFLAGS="$CXXFLAGS -target=$TARGET"Įxport SDKROOT="$(xcrun -sdk macosx -show-sdk-path)"Ĭmake -DCMAKE_C_COMPILER_TARGET="$TARGET" -DCMAKE_CXX_COMPILER_TARGET="$TARGET" -DCMAKE_SYSTEM_PROCESSOR="x86_64" -DCMAKE_SYSTEM_NAME="Darwin" -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS". ![]() I'm at the point where I'm looking at CocoaPods again - but that will not work with CMake, so we'll have two completely different build systems, one of which requires a Mac with GUI to add/remove sources/targets. Which is weird, because one of the things people use CMake for is to build Android and iOS apps, which generally does mean cross-compiling. googling and searching these fora hasn't shown a lot that seems to work (mainly, I think, for the vcpkg side). Not even universal, just "build for arm64 on Intel mac". I have not been able to figure out how to use CMake and vcpkg to do a cross build. (I could, theoretically, use lipo and create a universal bundle, but that would mean manually signing a handful of executables, and then the whole thing, unless I missed a way to do this much more easily?) We're using CircleCI for CI, or maybe github actions in the future. ![]() I want to support Apple Silicon, obviously. (TBF, I can't blame them for this, since this does work on a Mac, for at least a simple build.) As a result, the people who started 8 hours before I did picked CMake and vcpkg to handle build system generation and 3rd party dependencies. Again, none of this is really my choice: our project is multi-platform (specifically, at this time, Windows and macOS).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |