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

[feature] Allow overriding CMAKE_OSX_ARCHITECTURES for CMakeToolchain generator #9284

Closed
ssrobins opened this issue Jul 18, 2021 · 4 comments

Comments

@ssrobins
Copy link
Contributor

I'm building an iOS app that supports armv7 and arm64 architectures for maximum device compatibility. I currently accomplish that with the cmake generator by adding this to my conanfile.py:
cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = "armv7 arm64"

The conan package setting is arch=armv7, which is the best I can do without multiarch, but it gets the job done.

With the CMakeToolchain generator, the equivalent setting doesn't do anything:
tc.variables["CMAKE_OSX_ARCHITECTURES"] = "armv7 arm64"

I think the 'right way' to support this is to allow multiple architectures on platforms such as iOS and Android that allow that in the build. But if that's not feasible within the Conan 2.x release timeframe, being allowed to override CMAKE_OSX_ARCHITECTURES would give us the same capability we currently have in Conan 1.x.

@ssrobins
Copy link
Contributor Author

Any updates or suggested workarounds?

@memsharded
Copy link
Member

Hi @ssrobins

Yes, the CMAKE_OSX_ARCHITECTURES is defined by the CMakeToolchain, the AppleBlock.
You can override its value with (check https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html#extending-and-customizing-cmaketoolchain):

def generate(self):
    tc = CMakeToolchain(self)
    tc.blocks["apple_system"].values["cmake_osx_architectures"] = "...."
    tc.generate()

@ssrobins
Copy link
Contributor Author

Thanks, this works perfectly! I'm now completely converted to CMakeDeps/CMakeToolchain and mostly ready for Conan 2.0 :)
https://github.com/ssrobins/conan-recipes
Feel free to close this, if you like.

@memsharded
Copy link
Member

Excellent! Thanks for following up and reporting!

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

No branches or pull requests

2 participants