CMAKE_CROSSCOMPILING.rst 1.5 KB

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