Chapter 12, Cross-Platform-Compiling Custom Toolchains
- Toolchain files are passed either by the
--toolchaincommand-line flag, the
CMAKE_TOOLCHAIN_FILEvariable, or with the
toolchainFileoption in a CMake preset.
- Usually, the following things are done in a toolchain file for cross-compiling:
- Defining the target system and architecture
- Providing paths to any tools needed to build the software
- Setting default flags for the compiler and linkers
- Pointing to the sysroot and possibly any staging directory if cross-compiling
- Setting hints for the search order for any
find_commands of CMake
- The staging directory is set with the
CMAKE_STAGING_PREFIXvariable and is used as a place to install any built artifacts if the sysroot should not be modified.
- The emulator command is passed as a semicolon-separated list in the
- Any call to
enable_language()in a project will trigger detection of the features.
- The configuration...