]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add checks to cmake scripts to see if input files exist.
authorNathan Moinvaziri <nathan@nathanm.com>
Sat, 19 Sep 2020 23:04:58 +0000 (16:04 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 23 Sep 2020 20:34:55 +0000 (22:34 +0200)
cmake/run-and-redirect.cmake
cmake/test-compress.cmake

index e55fc3a43b0774f6532e9fa261f61fd40f5aa442..30c5741121cce6af50037a73007c0cdb2a51147a 100644 (file)
@@ -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
index ce04f914c62b857e0103ab5c90ca3d102c0474b9..338c7159ac42a4d88314c88af07dd5a63ffa2440 100644 (file)
@@ -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}"