blob: 0cc14d2d54af2e893d81db3203e0ba075a823c57 [file] [log] [blame]
Evan Nemerson93ef13f2016-06-20 13:07:35 -07001string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" REFERENCE_DATA "${INPUT}")
2get_filename_component(OUTPUT_NAME "${REFERENCE_DATA}" NAME)
3
4execute_process(
5 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
Evan Nemerson03657e82016-07-28 13:31:09 -07006 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress --input ${INPUT} --output ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro
Evan Nemerson93ef13f2016-06-20 13:07:35 -07007 RESULT_VARIABLE result)
8if(result)
9 message(FATAL_ERROR "Decompression failed")
10endif()
11
12function(test_file_equality f1 f2)
13 if(NOT CMAKE_VERSION VERSION_LESS 2.8.7)
14 file(SHA512 "${f1}" f1_cs)
15 file(SHA512 "${f2}" f2_cs)
16 if(NOT "${f1_cs}" STREQUAL "${f2_cs}")
17 message(FATAL_ERROR "Files do not match")
18 endif()
19 else()
20 file(READ "${f1}" f1_contents)
21 file(READ "${f2}" f2_contents)
22 if(NOT "${f1_contents}" STREQUAL "${f2_contents}")
23 message(FATAL_ERROR "Files do not match")
24 endif()
25 endif()
26endfunction()
27
28test_file_equality("${REFERENCE_DATA}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro")