-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[core] Update CMake to use TARGET_SDKS for Android #5095
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
[core] Update CMake to use TARGET_SDKS for Android #5095
Conversation
I think there are still more things that are similar than different here. I'd prefer you conditionalize the existing variables instead. |
Variables like |
It seems like a lot of those conditionals really want to be asking questions about the target platform, not the host platform. |
Absolutely. I'll try to think of a different way to accomplish this, but I wonder if it'll involve duplicating some of that logic. |
@jrose-apple Just to clarify: are you saying that the conditionals using |
Well, let's see:
|
The `add_swift_library` CMake function takes an optional `TARGET_SDKS` parameter. When used, only CMake targets for the specified SDKs are added. Change `stdlib/public/core` to use this parameter for Android, which prevents link flags intended for macOS/iOS targets from being used when building for Android.
8545ee0
to
4fb977f
Compare
I took another look at what part of these changes were really necessary to get things building. Some of the linker flags, like The one important thing to get the Android runtime building on macOS is to prevent framework dependencies on Foundation and CoreFoundation. I amended the pull request to share all parameters across the two target sets, but not set This is based on @gottesmm's comment in #5004, advising I reduce the scope of the changes. @jrose-apple, is this closer to what you had in mind? |
That new version doesn't handle ICU the way you wanted, correct? I really just want one call to |
Ah, OK, thanks! So basically we want this, but without using |
Well then I'm not happy about those either. :-) I'm not sure what the right answer is in general. I mostly like the SWIFT_MODULE_DEPENDS model, where we ended up adding variants for all the Apple platforms, but that has to be done manually for every argument and every platform variant right now. (And it doesn't allow groups like "all Apple platforms".) |
I feel like options should be added to all libraries by default, though, and that you should have to stop and think when it turns out they're only applicable to some. |
One option would be adding |
@modocache @jrose-apple I think that sounds like a reasonable solution. In general, I dislike declaring the same library multiple times. It feels like it is screaming to be refactored. |
It may be good to look into the other cases where we used the TARGET_SDKS for Android and see if we can do similar refactoring. |
I don't need this for building static libraries, so I'll close this for now. After #4972 is merged, I'll send another pull request with a different approach for dynamic libraries. |
Thanks for the reviews, though! Very much appreciated! |
The
add_swift_library
CMake function takes an optionalTARGET_SDKS
parameter. When used, only CMake targets for the specified SDKs are added.Change
stdlib/public/core
to use this parameter for Android, which prevents link flags intended for macOS/iOS targets from being used when building for Android.This pull request was split out of #4972, which addresses SR-1362.