1# Uniquely identify the toolchain wrt. its capabilities.
2#
3# What we are looking for, is a signature definition that is defined
4# like this:
5#  * The MD5 sum of the compiler itself. A MD5 checksum is taken of the content
6#    after symlinks are resolved. This ensure that if the content changes, then
7#    the MD5 will also change (as example toolchain upgrade in same folder)
8#  * The CMAKE_C_COMPILER itself. This may be a symlink, but it ensures that
9#    multiple symlinks pointing to same executable will generate different
10#    signatures, as example: clang, gcc, arm-zephyr-eabi-gcc, links pointing to
11#    ccache will generate unique signatures
12#  * CMAKE_C_COMPILER_ID is taking the CMake compiler id for extra signature.
13#  * CMAKE_C_COMPILER_VERSION will ensure that even when using the previous
14#    methods, where an upgraded compiler could have same signature due to ccache
15#    usage and symbolic links, then the upgraded compiler will have new version
16#    and thus generate a new signature.
17#
18#  Toolchains with the same signature will always support the same set of flags.
19#
20file(MD5 ${CMAKE_C_COMPILER} CMAKE_C_COMPILER_MD5_SUM)
21set(TOOLCHAIN_SIGNATURE ${CMAKE_C_COMPILER_MD5_SUM})
22
23# Extend the CMAKE_C_COMPILER_MD5_SUM with the compiler signature.
24string(MD5 COMPILER_SIGNATURE ${CMAKE_C_COMPILER}_${CMAKE_C_COMPILER_ID}_${CMAKE_C_COMPILER_VERSION})
25set(TOOLCHAIN_SIGNATURE ${TOOLCHAIN_SIGNATURE}_${COMPILER_SIGNATURE})
26
27# Load the compile features file which will provide compile features lists for
28# various C / CXX language dialects that can then be exported based on current
29# Zephyr Kconfig settings or the CSTD global property.
30include(${CMAKE_CURRENT_LIST_DIR}/compiler/compiler_features.cmake)
31
32# Loading of templates are strictly not needed as they do not set any
33# properties.
34# They purely provide an overview as well as a starting point for supporting
35# a new toolchain.
36include(${CMAKE_CURRENT_LIST_DIR}/compiler/compiler_flags_template.cmake)
37include(${CMAKE_CURRENT_LIST_DIR}/linker/linker_flags_template.cmake)
38
39# Configure the toolchain flags based on what toolchain technology is used
40# (gcc, host-gcc etc.)
41include(${TOOLCHAIN_ROOT}/cmake/compiler/${COMPILER}/compiler_flags.cmake OPTIONAL)
42include(${TOOLCHAIN_ROOT}/cmake/linker/${LINKER}/linker_flags.cmake OPTIONAL)
43