Files
esp-idf/components/xtensa/project_include.cmake
Frantisek Hrbata 427c5ba8df fix(xtensa/cmake): do not include project_include.cmake if the architecture is not xtensa
In cmakev2, the project_include.cmake files for every component are
included. This means that even when working with RISC-V, the
project_include.cmake file for Xtensa is still included. Ensure that the
architecture is verified, and exit if it is not Xtensa.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-10-30 17:17:49 +08:00

27 lines
964 B
CMake

idf_build_get_property(idf_target_arch IDF_TARGET_ARCH)
if(NOT "${idf_target_arch}" STREQUAL "xtensa")
return()
endif()
# Check toolchain is configured properly in cmake
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
# without '--target' option 'clang -dumpmachine' prints default target arch and it might be not Xtensa
# so use `-print-targets` option
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-targets
OUTPUT_VARIABLE dump_machine
)
else()
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE dump_machine
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
message(STATUS "Compiler supported targets: ${dump_machine}")
if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${dump_machine} MATCHES xtensa))
message(FATAL_ERROR "Internal error, toolchain has not been set correctly by project "
"(or an invalid CMakeCache.txt file has been generated somehow)")
endif()