blob: 39303d33f8f080dd3707883d4cfa0560326808f9 [file] [log] [blame]
Stephen Kyle67f059e2018-09-27 10:00:33 +01001set(ENV{QEMU_LD_PREFIX} "${BROTLI_WRAPPER_LD_PREFIX}")
2
Evan Nemerson93ef13f2016-06-20 13:07:35 -07003execute_process(
4 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +02005 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality=${QUALITY} ${INPUT} --output=${OUTPUT}.br
Evan Nemerson03657e82016-07-28 13:31:09 -07006 RESULT_VARIABLE result
7 ERROR_VARIABLE result_stderr)
Evan Nemerson93ef13f2016-06-20 13:07:35 -07008if(result)
Evan Nemerson03657e82016-07-28 13:31:09 -07009 message(FATAL_ERROR "Compression failed: ${result_stderr}")
Evan Nemerson93ef13f2016-06-20 13:07:35 -070010endif()
11
12execute_process(
13 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +020014 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress ${OUTPUT}.br --output=${OUTPUT}.unbr
Evan Nemerson93ef13f2016-06-20 13:07:35 -070015 RESULT_VARIABLE result)
16if(result)
17 message(FATAL_ERROR "Decompression failed")
18endif()
19
20function(test_file_equality f1 f2)
21 if(NOT CMAKE_VERSION VERSION_LESS 2.8.7)
22 file(SHA512 "${f1}" f1_cs)
23 file(SHA512 "${f2}" f2_cs)
24 if(NOT "${f1_cs}" STREQUAL "${f2_cs}")
25 message(FATAL_ERROR "Files do not match")
26 endif()
27 else()
28 file(READ "${f1}" f1_contents)
29 file(READ "${f2}" f2_contents)
30 if(NOT "${f1_contents}" STREQUAL "${f2_contents}")
31 message(FATAL_ERROR "Files do not match")
32 endif()
33 endif()
34endfunction()
35
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +020036test_file_equality("${INPUT}" "${OUTPUT}.unbr")