Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iOS Cross-Compilation Support #461

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Treata11
Copy link

Greetings,

Cross-compilation for a macOS target was already supported within this framework. To enable iOS compilations, I've introduced a new flag, IMATH_BUILD_APPLE_FRAMEWORKS, which is set to FALSE by default.

This implementation relies on the iOS-CMake toolchain for building.

Specifically, the following command can be used to build the project for iOS:

cmake -B build -G Xcode -DCMAKE_TOOLCHAIN_FILE=<path to ios.toolchain.cmake> -DPLATFORM=OS64 -DIMATH_BUILD_APPLE_FRAMEWORKS=ON 

Once built, the project can be installed using:

sudo cmake --build build --target install --config Release

The resulting iOS binaries can then be found in: build/src/Imath/Release-iphoneos/Imath-3_2.framework.

Copy link

linux-foundation-easycla bot commented Dec 24, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@meshula
Copy link
Contributor

meshula commented Dec 24, 2024

Thanks for thinking of this. I think it would be great to support create an ios framework as you propose, but I'm thinking it would be preferable to base it on the native cmake facilities for ios. As far as I understand it the leetal toolchain files are meant to support old cmake versions. We specify cmake 3.14, which I think is new enough to natively support iOS.

https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-visionos-or-watchos

Replaced `TBB_USE_APPLE_FRAMEWORKS` with `IMATH_BUILD_APPLE_FRAMEWORKS`.

Signed-off-by: Treata <[email protected]>
@Treata11
Copy link
Author

Treata11 commented Dec 24, 2024

Thanks for the tips @meshula !

As far as I understand it the leetal toolchain files are meant to support old cmake versions. We specify cmake 3.14, which I think is new enough to natively support iOS.

I wasn't able to produce iOS frameworks with the native CMake 3.14 flags... Are any adjustments in project's settings required for that?

@meshula
Copy link
Contributor

meshula commented Dec 26, 2024

I'd really prefer not to have to ask people to use a toolchain file as it really complicates builds of systems with many components, so hopefully it's possible with CMake. I'm unclear if we need to bump to a later CMake version, or if there's a deeper problem. Adding @dgovil for advice, as he's been deep into producing cmake based framework builds for other projects recently.

@dgovil
Copy link

dgovil commented Dec 26, 2024

You shouldn't need toolchains if using recent CMake versions like 3.19 for iOS I believe and 3.28 for visionOS.

You can just set the CMAKE_SYSTEM_NAME to the appropriate platform version, and it'll find the correct SDK toolchain for you automatically.

@meshula
Copy link
Contributor

meshula commented Dec 26, 2024

Thanks! If 3.19 works, we could bump the min version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants