execute_process and add_custom_target behave differently with respect to COMMAND
Dear CMake Folks, I have a strange issue, I need to run matlab script and use the generated code for compilation. I would like to run matlab2018b(64 bit) in Windows without display and I am using MinGW as makefile generator. For me this works without the display but is not intended (I need generation before build)
add_custom_target(generate_sources ALL COMMAND ${Matlab_MAIN_PROGRAM} -nosplash -nodesktop -noFigureWindows -minimize -wait -log -r "matlab_script"
While this works with matlab display:
execute_process(
COMMAND "${Matlab_MAIN_PROGRAM}" -nosplash -nodesktop -noFigureWindows -minimize -wait -log -r "matlab_script"
ERROR_VARIABLE STDERR
RESULT_VARIABLE RES
TIMEOUT 600
INPUT_FILE NUL
COMMAND_ECHO STDOUT)
message("OUTPUT variable is: ${RES}")
if(NOT (RES EQUAL 0) OR STDERR MATCHES "\\?\\?\\? Error")
message( FATAL_ERROR "execute_process returned ${RES}" )
endif()
I would like to use execute_process as it is meant during config time. I suspect there is something in the way that I specify COMMAND in both cases. Could you please help?
Thanks!
Edited by Brad King