1 # Function to check the toolchain used the expected version
2 # of crosstool, and warn otherwise
4 set(ctng_version_warning "Check Getting Started documentation or proceed at own risk.")
6 function(gcc_version_check expected_gcc_version)
7 if(NOT "${CMAKE_C_COMPILER_VERSION}" STREQUAL "${expected_gcc_version}")
8 message(WARNING "Xtensa toolchain ${CMAKE_C_COMPILER} version ${CMAKE_C_COMPILER_VERSION} "
9 "is not the supported version ${expected_gcc_version}. ${ctng_version_warning}")
13 function(crosstool_version_check expected_ctng_version)
15 COMMAND ${CMAKE_C_COMPILER} -v
16 ERROR_VARIABLE toolchain_stderr
19 string(REGEX MATCH "crosstool-ng-[0-9a-g\\.-]+" ctng_version "${toolchain_stderr}")
20 string(REPLACE "crosstool-ng-" "" ctng_version "${ctng_version}")
21 # We use FIND to match version instead of STREQUAL because some toolchains are built
22 # with longer git hash strings than others. This will match any version which starts with
23 # the expected version string.
24 string(FIND "${ctng_version}" "${expected_ctng_version}" found_expected_version)
26 message(WARNING "Xtensa toolchain ${CMAKE_C_COMPILER} does not appear to be built with crosstool-ng. "
27 "${ctng_version_warning}")
28 elseif(found_expected_version EQUAL -1)
29 message(WARNING "Xtensa toolchain ${CMAKE_C_COMPILER} crosstool-ng version ${ctng_version} "
30 "doesn't match supported version ${expected_ctng_version}. ${ctng_version_warning}")