@@ -24,11 +24,12 @@ if(NO_PREBUILT)
2424 set (extraFlags "-DNO_PREBUILT=1" )
2525endif ()
2626
27- # overload execute_process: Exit on cperror code.
28- function (execute_process)
29- _execute_process(${ARGV} RESULT_VARIABLE error)
30- if (error)
31- message (FATAL_ERROR "" )
27+ # Execute process and fail on error (via RESULT_VARIABLE).
28+ # COMMAND_ERROR_IS_FATAL is an alternative but requires CMake 3.19+
29+ function (execute_process_fail_on_error)
30+ execute_process (${ARGV} RESULT_VARIABLE _execute_error)
31+ if (_execute_error)
32+ message (FATAL_ERROR "Failed with exit code ${_execute_error} : ${ARGV} " )
3233 endif ()
3334endfunction ()
3435
@@ -74,12 +75,12 @@ function(configureAndBuild multi generator)
7475 message (STATUS "-------------------------------------------------------" )
7576 message (STATUS "**** Test Generator: ${generator} with test project '${project} ' and variant '${variant} '." )
7677 message (STATUS "-------------------------------------------------------" )
77- execute_process (COMMAND ${CMAKE_COMMAND} -S ${srcdir} -B ${builddir} -G ${generator} ${configureFlags} ${extraFlags} )
78+ execute_process_fail_on_error (COMMAND ${CMAKE_COMMAND} -S " ${srcdir} " -B " ${builddir} " -G " ${generator} " ${configureFlags} ${extraFlags} )
7879 if (multi)
79- execute_process (COMMAND ${CMAKE_COMMAND} --build ${builddir} --config Release)
80- execute_process (COMMAND ${CMAKE_COMMAND} --build ${builddir} --config Debug)
80+ execute_process_fail_on_error (COMMAND ${CMAKE_COMMAND} --build " ${builddir} " --config Release)
81+ execute_process_fail_on_error (COMMAND ${CMAKE_COMMAND} --build " ${builddir} " --config Debug)
8182 else ()
82- execute_process (COMMAND ${CMAKE_COMMAND} --build ${builddir} )
83+ execute_process_fail_on_error (COMMAND ${CMAKE_COMMAND} --build " ${builddir} " )
8384 endif ()
8485 endforeach ()
8586 endforeach ()
0 commit comments