]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added option to normalize line-endings in CMake run-and-compare script.
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 20 Sep 2020 23:01:03 +0000 (16:01 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 23 Sep 2020 20:34:55 +0000 (22:34 +0200)
CMakeLists.txt
cmake/run-and-compare.cmake

index 6bdf9c7d707a729fe013cc4167a6277d2f2403d1..ce103f6a7ccdcc47362c84c2bfe9fab6493d6da1 100644 (file)
@@ -1089,6 +1089,7 @@ if(ZLIB_ENABLE_TESTS)
         "-DCOMMAND=${MAKEFIXED_COMMAND}"
         -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/inffixed_tbl._h
         -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/inffixed_tbl.h
+        -DIGNORE_LINE_ENDINGS=ON
         -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake)
 
     add_executable(maketrees tools/maketrees.c trees.c zutil.c)
@@ -1100,6 +1101,7 @@ if(ZLIB_ENABLE_TESTS)
         "-DCOMMAND=${MAKETREES_COMMAND}"
         -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/trees_tbl._h
         -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/trees_tbl.h
+        -DIGNORE_LINE_ENDINGS=ON
         -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake)
 
     add_executable(makecrct tools/makecrct.c)
@@ -1111,6 +1113,7 @@ if(ZLIB_ENABLE_TESTS)
         "-DCOMMAND=${MAKECRCT_COMMAND}"
         -DOUTPUT=${CMAKE_CURRENT_SOURCE_DIR}/crc32_tbl._h
         -DCOMPARE=${CMAKE_CURRENT_SOURCE_DIR}/crc32_tbl.h
+        -DIGNORE_LINE_ENDINGS=ON
         -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake)
 
     if(WITH_FUZZERS)
index 62657992574f3f7487c7623337d46770e6476ad1..0e934337314f3c25c96e4762e0d4e609b0774e69 100644 (file)
@@ -25,11 +25,24 @@ if(CMD_RESULT)
     message(FATAL_ERROR "Run before compare failed: ${CMD_RESULT}")
 endif()
 
+# Use configure_file to normalize line-endings
+if(IGNORE_LINE_ENDINGS)
+    configure_file(${COMPARE} ${COMPARE}.cmp NEWLINE_STYLE LF)
+    set(COMPARE ${COMPARE}.cmp)
+    configure_file(${OUTPUT} ${OUTPUT}.cmp NEWLINE_STYLE LF)
+    set(OUTPUT ${OUTPUT}.cmp)
+endif()
+
 # Compare that output is equal to specified file
 execute_process(COMMAND ${CMAKE_COMMAND}
     -E compare_files ${COMPARE} ${OUTPUT}
     RESULT_VARIABLE CMD_RESULT)
 
+# Delete temporary files used to normalize line-endings
+if(IGNORE_LINE_ENDINGS)
+    file(REMOVE ${COMPARE} ${OUTPUT})
+endif()
+
 if(CMD_RESULT)
     message(FATAL_ERROR "Run compare failed: ${CMD_RESULT}")
 endif()
\ No newline at end of file