1string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" REFERENCE_DATA "${INPUT}") 2string(REGEX REPLACE "\\.compressed" "" OUTPUT_FILE "${INPUT}") 3get_filename_component(OUTPUT_NAME "${OUTPUT_FILE}" NAME) 4 5set(ENV{QEMU_LD_PREFIX} "${BROTLI_WRAPPER_LD_PREFIX}") 6 7execute_process( 8 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 9 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress ${INPUT} --output=${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbr 10 RESULT_VARIABLE result) 11if(result) 12 message(FATAL_ERROR "Decompression failed") 13endif() 14 15function(test_file_equality f1 f2) 16 if(NOT CMAKE_VERSION VERSION_LESS 2.8.7) 17 file(SHA512 "${f1}" f1_cs) 18 file(SHA512 "${f2}" f2_cs) 19 if(NOT "${f1_cs}" STREQUAL "${f2_cs}") 20 message(FATAL_ERROR "Files do not match") 21 endif() 22 else() 23 file(READ "${f1}" f1_contents) 24 file(READ "${f2}" f2_contents) 25 if(NOT "${f1_contents}" STREQUAL "${f2_contents}") 26 message(FATAL_ERROR "Files do not match") 27 endif() 28 endif() 29endfunction() 30 31test_file_equality("${REFERENCE_DATA}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbr") 32