Skip to content

[CMake] Replace APPLE with CMAKE_HOST_APPLE #5231

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

Closed
wants to merge 1 commit into from

Conversation

modocache
Copy link
Contributor

In CMake APPLE is defined if you are targeting an Apple platform (or at least if CMake thinks you are). If your host is an Apple platform CMake defines CMAKE_HOST_APPLE.

Swift's build system is rolling its own cross-compiling support, so checks such as APPLE do not function properly, and instead are true when the host is APPLE. To make that fact explicit, change these variables to CMAKE_HOST_APPLE.

Addresses a comment by @llvm-beanz on #5160 (comment).

In CMake `APPLE` is defined if you are *targeting* an Apple platform (or
at least if CMake thinks you are). If your host is an Apple platform
CMake defines `CMAKE_HOST_APPLE`.

Swift's build system is rolling its own cross-compiling support, so checks such
as `APPLE` do not function properly, and instead are true when the
*host* is `APPLE`. To make that fact explicit, change these variables to
`CMAKE_HOST_APPLE`.
@jrose-apple
Copy link
Contributor

I don't think this is correct. We don't care about the system SourceKit is being built on; we care about where it will be run.

@llvm-beanz
Copy link
Contributor

@jrose-apple is right on these checks. These if(APPLE) checks are actually checking for the target being Apple platforms. Sadly that means that these checks would go awry with the swift-rolled cross compiling if you are on a Mac targeting Android (or any other non-Apple platform).

You may need to feed an SDK check in through here.

@jrose-apple
Copy link
Contributor

jrose-apple commented Oct 11, 2016

An SDK check isn't correct either—there may be up to three systems here:

  • "build" (what CMake calls "host"): the system where CMake is being run and where the compilation is happening
  • "host": the system where the Swift compiler and SourceKit and such will be run
  • "target": the system(s) where the stdlib and overlay code will be run

Obviously if "build" and "host" are different then you can't build any target libraries in this compilation (at least without using some kind of "native tools", which we do have a setting for), but that may be okay.

@modocache
Copy link
Contributor Author

I'll close this for now, in favor of a broader approach (hopefully) coming soon.

@modocache modocache closed this Oct 18, 2016
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.

4 participants