Commit 18ed861
committed
CMake: Fixing cross-compiling Swift-Foundation
The macros must build for the local machine running the build, not the
machine that Swift-Foundation will run on, in order for the build to be
able to use the macros.
To do this, the macro build must use ExternalProject, which treats the
child project as an entirely independent project. One cannot introspect
into the external project since it is configured at build time, rather
than at configure time. This is what allows the external project to
build for another platform.
The expectation is that the calling project will pull the built products
of the ExternalProject from the install location. EPs have an internal
implicit install prefix where they can install stuff to without dirtying
the building machine or installed products, so we can make use of that.
In order for that to work, the products must actually get installed
though, so we have to install the FoundationMacros, even when built as
an executable. To support that, I've exposed an option to tell the
macro build to build the macros as an executable.
On the library side, I've exposed the Foundation macros as an interface
library that only exposes the `-load-plugin-path` option needed for
picking up the macro. Linking against this interface library will load
the plugin as desired.
This results in a build that
- can use macros, even when cross-compiling.
- does not install the macros into the installed library, only to the
build directory.1 parent c2e96f8 commit 18ed861
File tree
5 files changed
+45
-32
lines changed- Sources
- FoundationEssentials
- FoundationMacros
- cmake/modules
5 files changed
+45
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
15 | 47 | | |
16 | 48 | | |
17 | 49 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | 52 | | |
76 | 53 | | |
77 | 54 | | |
| |||
88 | 65 | | |
89 | 66 | | |
90 | 67 | | |
| 68 | + | |
91 | 69 | | |
92 | 70 | | |
93 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
0 commit comments