CMake: Refactor ADDITIONAL_CHECK_TYPES to XZ_CHECKS

Now "crc32" is in the list too for completeness but it doesn't
actually have any effect. The description of the cache variable
says that "crc32 is always built" so it should be clear enough.
This commit is contained in:
Lasse Collin 2024-06-15 18:07:04 +03:00
parent 679500ffe0
commit 96abfe98c1
2 changed files with 15 additions and 16 deletions

View File

@ -503,13 +503,13 @@ endif()
# Checks #
##########
set(ADDITIONAL_SUPPORTED_CHECKS crc64 sha256)
set(SUPPORTED_CHECKS crc32 crc64 sha256)
set(ADDITIONAL_CHECK_TYPES "${ADDITIONAL_SUPPORTED_CHECKS}" CACHE STRING
"Additional check types to support (crc32 is always built)")
set(XZ_CHECKS "${SUPPORTED_CHECKS}" CACHE STRING
"Check types to support (crc32 is always built)")
foreach(CHECK IN LISTS ADDITIONAL_CHECK_TYPES)
if(NOT CHECK IN_LIST ADDITIONAL_SUPPORTED_CHECKS)
foreach(CHECK IN LISTS XZ_CHECKS)
if(NOT CHECK IN_LIST SUPPORTED_CHECKS)
message(FATAL_ERROR "'${CHECK}' is not a supported check type")
endif()
endforeach()
@ -530,7 +530,7 @@ else()
endif()
endif()
if("crc64" IN_LIST ADDITIONAL_CHECK_TYPES)
if("crc64" IN_LIST XZ_CHECKS)
add_compile_definitions("HAVE_CHECK_CRC64")
if(XZ_SMALL)
@ -550,7 +550,7 @@ if("crc64" IN_LIST ADDITIONAL_CHECK_TYPES)
endif()
endif()
if("sha256" IN_LIST ADDITIONAL_CHECK_TYPES)
if("sha256" IN_LIST XZ_CHECKS)
add_compile_definitions("HAVE_CHECK_SHA256")
target_sources(liblzma PRIVATE src/liblzma/check/sha256.c)
endif()

View File

@ -108,17 +108,16 @@ if(BUILD_TESTING)
set(HAVE_ALL_DECODERS OFF)
endif()
set(ADDITIONAL_SUPPORTED_CHECKS_SORTED "${ADDITIONAL_SUPPORTED_CHECKS}")
list(SORT ADDITIONAL_SUPPORTED_CHECKS_SORTED)
set(SUPPORTED_CHECKS_SORTED "${SUPPORTED_CHECKS}")
list(SORT SUPPORTED_CHECKS_SORTED)
set(ADDITIONAL_CHECK_TYPES_SORTED "${ADDITIONAL_CHECK_TYPES}")
list(SORT ADDITIONAL_CHECK_TYPES_SORTED)
set(XZ_CHECKS_SORTED "${XZ_CHECKS}")
list(SORT XZ_CHECKS_SORTED)
if("${ADDITIONAL_SUPPORTED_CHECKS_SORTED}" STREQUAL
"${ADDITIONAL_CHECK_TYPES_SORTED}")
set(HAVE_ALL_CHECK_TYPES ON)
if("${SUPPORTED_CHECKS_SORTED}" STREQUAL "${XZ_CHECKS_SORTED}")
set(HAVE_ALL_CHECKS ON)
else()
set(HAVE_ALL_CHECK_TYPES OFF)
set(HAVE_ALL_CHECKS OFF)
endif()
# test_scripts.sh only needs LZMA2 decoder and CRC32.
@ -178,7 +177,7 @@ if(BUILD_TESTING)
# test_files.sh decompresses files that use different filters and
# check types so run it only if support for all of them has been enabled.
if(UNIX AND HAVE_ALL_DECODERS AND HAVE_ALL_CHECK_TYPES AND XZ_LZIP_DECODER)
if(UNIX AND HAVE_ALL_DECODERS AND HAVE_ALL_CHECKS AND XZ_LZIP_DECODER)
# test_files.sh doesn't make any temporary files but it
# must not be run at the top-level build directory because
# it checks if ../config.h exists. We don't want to read