file(MAKE_DIRECTORY dir) file(WRITE dir/in.txt "This is a test") execute_process(COMMAND ${PRINT_STDIN_EXE} WORKING_DIRECTORY dir INPUT_FILE in.txt OUTPUT_FILE out.txt ERROR_FILE err.txt) if(NOT EXISTS dir/out.txt) message(SEND_ERROR "Did not create dir/out.txt") endif() file(READ dir/out.txt out) if(NOT out STREQUAL "This is a test") message(SEND_ERROR "Did not read dir/in.txt") endif() if(NOT EXISTS dir/err.txt) message(SEND_ERROR "Did not create dir/err.txt") endif()