diff --git a/cmake/bintools/gnu/target.cmake b/cmake/bintools/gnu/target.cmake index 65b63c507ea..bef546c82c4 100644 --- a/cmake/bintools/gnu/target.cmake +++ b/cmake/bintools/gnu/target.cmake @@ -12,6 +12,23 @@ find_program(CMAKE_NM ${CROSS_COMPILE}nm PATHS ${TOOLCHAIN_HOME} NO_DE find_program(CMAKE_STRIP ${CROSS_COMPILE}strip PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) find_program(CMAKE_GDB ${CROSS_COMPILE}gdb PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) + +if(CMAKE_GDB) + execute_process( + COMMAND ${CMAKE_GDB} --configuration + OUTPUT_VARIABLE GDB_PY_NO_PY + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULTS_VARIABLE GDB_CFG_ERR + ) + if (${GDB_CFG_ERR}) + # Failed to execute GDB, likely because of Python deps + find_program(CMAKE_GDB_NO_PY ${CROSS_COMPILE}gdb-no-py PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) + if (CMAKE_GDB_NO_PY) + set(CMAKE_GDB ${CMAKE_GDB_NO_PY} CACHE FILEPATH "Path to a program." FORCE) + endif() + endif() +endif() + find_program(CMAKE_GDB gdb-multiarch PATHS ${TOOLCHAIN_HOME} ) # Include bin tool properties