blob: fbbd4062e6f373e1e3c8cac1c20cc5b7115c537b [file] [log] [blame]
Evan Nemerson93ef13f2016-06-20 13:07:35 -07001execute_process(
2 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Evan Nemerson03657e82016-07-28 13:31:09 -07003 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality ${QUALITY} --input ${INPUT} --output ${OUTPUT}.bro
4 RESULT_VARIABLE result
5 ERROR_VARIABLE result_stderr)
Evan Nemerson93ef13f2016-06-20 13:07:35 -07006if(result)
Evan Nemerson03657e82016-07-28 13:31:09 -07007 message(FATAL_ERROR "Compression failed: ${result_stderr}")
Evan Nemerson93ef13f2016-06-20 13:07:35 -07008endif()
9
10execute_process(
11 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Evan Nemerson03657e82016-07-28 13:31:09 -070012 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress --input ${OUTPUT}.bro --output ${OUTPUT}.unbro
Evan Nemerson93ef13f2016-06-20 13:07:35 -070013 RESULT_VARIABLE result)
14if(result)
15 message(FATAL_ERROR "Decompression failed")
16endif()
17
18function(test_file_equality f1 f2)
19 if(NOT CMAKE_VERSION VERSION_LESS 2.8.7)
20 file(SHA512 "${f1}" f1_cs)
21 file(SHA512 "${f2}" f2_cs)
22 if(NOT "${f1_cs}" STREQUAL "${f2_cs}")
23 message(FATAL_ERROR "Files do not match")
24 endif()
25 else()
26 file(READ "${f1}" f1_contents)
27 file(READ "${f2}" f2_contents)
28 if(NOT "${f1_contents}" STREQUAL "${f2_contents}")
29 message(FATAL_ERROR "Files do not match")
30 endif()
31 endif()
32endfunction()
33
Evan Nemerson03657e82016-07-28 13:31:09 -070034test_file_equality("${INPUT}" "${OUTPUT}.unbro")