1# Check toolchain is configured properly in cmake 2if(CMAKE_C_COMPILER_ID MATCHES "Clang") 3 # without '--target' option 'clang -dumpmachine' prints default target arch and it might be not Xtensa 4 # so use `-print-targets` option 5 execute_process( 6 COMMAND ${CMAKE_C_COMPILER} -print-targets 7 OUTPUT_VARIABLE dump_machine 8 ) 9else() 10 execute_process( 11 COMMAND ${CMAKE_C_COMPILER} -dumpmachine 12 OUTPUT_VARIABLE dump_machine 13 ) 14endif() 15message("Compiler supported targets: ${dump_machine}") 16 17if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${dump_machine} MATCHES xtensa)) 18 message(FATAL_ERROR "Internal error, toolchain has not been set correctly by project " 19 "(or an invalid CMakeCache.txt file has been generated somehow)") 20endif() 21