zephyr/cmake/toolchain
Torsten Rasmussen fd9e5429a3 cmake: detect sysroot for cross-compile toolchains
Fixes: #49587

Try to detect sysroot for cross-compile toolchain if not specified by
the user with `-DSYSROOT_DIR=<path>`.

First, the C compiler is asked if it knows its sysroot, some C compilers
are able to return the sysroot, as an example:
> $ arm-none-eabi-gcc -print-sysroot
> <path>/bin/../arm-none-eabi
> $

but majority of gcc-based C compilers seems to return empty string:
> $ arm-zephyr-eabi-gcc --print-sysroot
> $

in such cases, the cross-compiler target CMake file will try to discover
the sysroot by searching for libc.a, starting one level up from the
compiler location.

If no sysroot candidate is found, a warning will be printed to the user.
If a single sysroot candidate is found, this candidate will be selected.
If multiply sysroot candidates are found, a warning is printed, and the
first candiate in the list is selected. User may select another
candidate with `-DSYSROOT_DIR=<use-this>`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-09-23 16:37:44 +02:00
..
arcmwdt cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
armclang cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
cross-compile cmake: detect sysroot for cross-compile toolchains 2022-09-23 16:37:44 +02:00
espressif cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
gnuarmemb cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
host cmake: toolchain: print what we find 2020-03-10 14:53:28 +02:00
llvm cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
oneApi cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
xcc cmake: use zephyr_get in toolchains to ensure identical behavior. 2022-09-02 15:16:50 +02:00
xcc-clang cmake: Add xcc-clang toolchain 2022-02-25 11:17:06 -05:00
xtools toolchain/xtools: Crosstools-ng supports TLS by default 2022-09-08 21:36:37 +00:00
zephyr cmake: rework of host tools and generic toolchain handling 2022-09-01 15:59:43 +02:00