1CMAKE_CROSSCOMPILING
2--------------------
3
4Intended to indicate whether CMake is cross compiling, but note limitations
5discussed below.
6
7This variable will be set to true by CMake if the :variable:`CMAKE_SYSTEM_NAME`
8variable has been set manually (i.e. in a toolchain file or as a cache entry
9from the :manual:`cmake <cmake(1)>` command line). In most cases, manually
10setting :variable:`CMAKE_SYSTEM_NAME` will only be done when cross compiling,
11since it will otherwise be given the same value as
12:variable:`CMAKE_HOST_SYSTEM_NAME` if not manually set, which is correct for
13the non-cross-compiling case. In the event that :variable:`CMAKE_SYSTEM_NAME`
14is manually set to the same value as :variable:`CMAKE_HOST_SYSTEM_NAME`, then
15``CMAKE_CROSSCOMPILING`` will still be set to true.
16
17Another case to be aware of is that builds targeting Apple platforms other than
18macOS are handled differently to other cross compiling scenarios. Rather than
19relying on :variable:`CMAKE_SYSTEM_NAME` to select the target platform, Apple
20device builds use :variable:`CMAKE_OSX_SYSROOT` to select the appropriate SDK,
21which indirectly determines the target platform. Furthermore, when using the
22:generator:`Xcode` generator, developers can switch between device and
23simulator builds at build time rather than having a single
24choice at configure time, so the concept
25of whether the build is cross compiling or not is more complex. Therefore, the
26use of ``CMAKE_CROSSCOMPILING`` is not recommended for projects targeting Apple
27devices.
28