Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 1 | execute_process( |
| 2 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame^] | 3 | COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality ${QUALITY} --input ${INPUT} --output ${OUTPUT}.bro |
| 4 | RESULT_VARIABLE result |
| 5 | ERROR_VARIABLE result_stderr) |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 6 | if(result) |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame^] | 7 | message(FATAL_ERROR "Compression failed: ${result_stderr}") |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 8 | endif() |
| 9 | |
| 10 | execute_process( |
| 11 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame^] | 12 | COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress --input ${OUTPUT}.bro --output ${OUTPUT}.unbro |
Evan Nemerson | 93ef13f | 2016-06-20 13:07:35 -0700 | [diff] [blame] | 13 | RESULT_VARIABLE result) |
| 14 | if(result) |
| 15 | message(FATAL_ERROR "Decompression failed") |
| 16 | endif() |
| 17 | |
| 18 | function(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() |
| 32 | endfunction() |
| 33 | |
Evan Nemerson | 03657e8 | 2016-07-28 13:31:09 -0700 | [diff] [blame^] | 34 | test_file_equality("${INPUT}" "${OUTPUT}.unbro") |