• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# If no output is specified, discard output
2if(NOT OUTPUT)
3    if(WIN32)
4        set(OUTPUT NUL)
5    else()
6        set(OUTPUT /dev/null)
7    endif()
8endif()
9
10if(INPUT)
11    # Execute with both stdin and stdout file
12    execute_process(COMMAND ${COMMAND}
13        RESULT_VARIABLE CMD_RESULT
14        INPUT_FILE ${INPUT}
15        OUTPUT_FILE ${OUTPUT})
16else()
17    # Execute with only stdout file
18    execute_process(COMMAND ${COMMAND}
19        RESULT_VARIABLE CMD_RESULT
20        OUTPUT_FILE ${OUTPUT})
21endif()
22
23# Check if exit code is in list of successful exit codes
24if(SUCCESS_EXIT)
25    list(FIND SUCCESS_EXIT ${CMD_RESULT} _INDEX)
26    if (${_INDEX} GREATER -1)
27        set(CMD_RESULT 0)
28    endif()
29endif()
30
31# Check to see if successful
32if(CMD_RESULT)
33    message(FATAL_ERROR "${COMMAND} failed: ${CMD_RESULT}")
34endif()
35