From: Nathan Moinvaziri Date: Sat, 19 Sep 2020 23:04:58 +0000 (-0700) Subject: Add checks to cmake scripts to see if input files exist. X-Git-Tag: 1.9.9-b1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a19b6af327b947c9d5576a958cdb76090a012bd;p=thirdparty%2Fzlib-ng.git Add checks to cmake scripts to see if input files exist. --- diff --git a/cmake/run-and-redirect.cmake b/cmake/run-and-redirect.cmake index e55fc3a4..30c57411 100644 --- a/cmake/run-and-redirect.cmake +++ b/cmake/run-and-redirect.cmake @@ -8,6 +8,10 @@ if(NOT DEFINED OUTPUT) endif() if(INPUT) + # Check to see that input file exists + if(NOT EXISTS ${INPUT}) + message(FATAL_ERROR "Cannot find input: ${INPUT}") + endif() # Execute with both stdin and stdout file execute_process(COMMAND ${COMMAND} RESULT_VARIABLE CMD_RESULT diff --git a/cmake/test-compress.cmake b/cmake/test-compress.cmake index ce04f914..338c7159 100644 --- a/cmake/test-compress.cmake +++ b/cmake/test-compress.cmake @@ -39,6 +39,10 @@ macro(cleanup) endmacro() # Compress input file +if(NOT EXISTS ${INPUT}) + message(FATAL_ERROR "Cannot find compress input: ${INPUT}") +endif() + set(COMPRESS_COMMAND ${COMPRESS_TARGET} ${COMPRESS_ARGS}) execute_process(COMMAND ${CMAKE_COMMAND} @@ -55,6 +59,11 @@ if(CMD_RESULT) endif() # Decompress output +if(NOT EXISTS ${OUTPUT}.gz) + cleanup() + message(FATAL_ERROR "Cannot find decompress input: ${OUTPUT}.gz") +endif() + set(DECOMPRESS_COMMAND ${DECOMPRESS_TARGET} ${DECOMPRESS_ARGS}) execute_process(COMMAND ${CMAKE_COMMAND} @@ -86,6 +95,11 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") # Transparent writing does not use gzip format find_program(GZIP gzip) if(GZIP) + if(NOT EXISTS ${OUTPUT}.gz) + cleanup() + message(FATAL_ERROR "Cannot find gzip decompress input: ${OUTPUT}.gz") + endif() + # Check gzip can decompress our compressed output set(GZ_DECOMPRESS_COMMAND ${GZIP} --decompress) @@ -112,6 +126,11 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") message(FATAL_ERROR "Compare gzip decompress failed: ${CMD_RESULT}") endif() + if(NOT EXISTS ${OUTPUT}.gz) + cleanup() + message(FATAL_ERROR "Cannot find gzip compress input: ${INPUT}") + endif() + # Compress input file with gzip set(GZ_COMPRESS_COMMAND ${GZIP} --stdout) @@ -128,6 +147,11 @@ if(GZIP_VERIFY AND NOT "${COMPRESS_ARGS}" MATCHES "-T") message(FATAL_ERROR "Gzip compress failed: ${CMD_RESULT}") endif() + if(NOT EXISTS ${OUTPUT}.gz) + cleanup() + message(FATAL_ERROR "Cannot find minigzip decompress input: ${OUTPUT}.gzip.gz") + endif() + # Check minigzip can decompress gzip compressed output execute_process(COMMAND ${CMAKE_COMMAND} "-DCOMMAND=${DECOMPRESS_COMMAND}"