From cf131fdc55ee21f8811f2e5ab06645fa7cb2763a Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Tue, 4 Mar 2025 09:33:03 -0800 Subject: [PATCH] Improve error messages when embedSdf.py fails Check embedSdf.py return code and print stderr on failure. Partial backport of #1549. Signed-off-by: Steve Peters --- sdf/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdf/CMakeLists.txt b/sdf/CMakeLists.txt index 10e789bfa..6f41293a7 100644 --- a/sdf/CMakeLists.txt +++ b/sdf/CMakeLists.txt @@ -19,11 +19,18 @@ endif() # Generate the EmbeddedSdf.cc file, which contains all the supported SDF # descriptions in a map of strings. The parser.cc file uses EmbeddedSdf.hh. +set(EMBEDDED_SDF_CC_PATH "${PROJECT_BINARY_DIR}/src/EmbeddedSdf.cc") execute_process( COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sdf/embedSdf.py - --output-file "${PROJECT_BINARY_DIR}/src/EmbeddedSdf.cc" + --output-file "${EMBEDDED_SDF_CC_PATH}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/sdf" + RESULT_VARIABLE EMBEDDED_SDF_RESULT + ERROR_VARIABLE EMBEDDED_SDF_ERROR ) +# check process return code +if(NOT EMBEDDED_SDF_RESULT EQUAL 0) + message(FATAL_ERROR "Error executing ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sdf/embedSdf.py to create ${EMBEDDED_SDF_CC_PATH}: ${EMBEDDED_SDF_ERROR}") +endif() # Generate aggregated SDF description files for use by the sdformat.org # website. If the description files change, the generated full*.sdf files need