if(NOT DEFINED PANO_CLI) message(FATAL_ERROR "PANO_CLI must be set") endif() if(NOT DEFINED OUTPUT_PATH) message(FATAL_ERROR "OUTPUT_PATH must be set") endif() get_filename_component(output_dir "${OUTPUT_PATH}" DIRECTORY) file(MAKE_DIRECTORY "${output_dir}") file(REMOVE "${OUTPUT_PATH}") execute_process( COMMAND "${PANO_CLI}" save-project --path "${OUTPUT_PATH}" --width 96 --height 48 --layer-name Roundtrip --frame-duration-ms 321 RESULT_VARIABLE save_result OUTPUT_VARIABLE save_output ERROR_VARIABLE save_error) if(NOT save_result EQUAL 0) message(FATAL_ERROR "save-project failed: ${save_output}${save_error}") endif() string(FIND "${save_output}" "\"command\":\"save-project\"" save_command_index) string(FIND "${save_output}" "\"bytes\":65655" save_bytes_index) if(save_command_index LESS 0 OR save_bytes_index LESS 0) message(FATAL_ERROR "save-project output did not contain expected summary: ${save_output}") endif() if(NOT EXISTS "${OUTPUT_PATH}") message(FATAL_ERROR "save-project did not create ${OUTPUT_PATH}") endif() execute_process( COMMAND "${PANO_CLI}" load-project --path "${OUTPUT_PATH}" RESULT_VARIABLE load_result OUTPUT_VARIABLE load_output ERROR_VARIABLE load_error) if(NOT load_result EQUAL 0) message(FATAL_ERROR "load-project failed after save-project: ${load_output}${load_error}") endif() string(FIND "${load_output}" "\"command\":\"load-project\"" load_command_index) string(FIND "${load_output}" "\"width\":96" load_width_index) string(FIND "${load_output}" "\"height\":48" load_height_index) string(FIND "${load_output}" "\"animationDurationMs\":321" load_duration_index) string(FIND "${load_output}" "\"layerNames\":[\"Roundtrip\"]" load_layer_index) if(load_command_index LESS 0 OR load_width_index LESS 0 OR load_height_index LESS 0 OR load_duration_index LESS 0 OR load_layer_index LESS 0) message(FATAL_ERROR "load-project output did not contain expected round-trip summary: ${load_output}") endif()