CMake: Use FATAL_ERROR if user-supplied options aren't understood.

This way typos are caught quickly and compounding error messages
are avoided (a single typo could cause more than one error).

This keeps using SEND_ERROR when the system is lacking a feature
(like threading library or sandboxing method). This way the whole
configuration log will be generated in case someone wishes to
report a problem upstream.
This commit is contained in:
Lasse Collin 2023-10-09 20:59:24 +03:00 committed by Jia Tan
parent 1695021e4a
commit f8edcf3da6
1 changed files with 14 additions and 14 deletions

View File

@ -272,7 +272,7 @@ set(ADDITIONAL_CHECK_TYPES "${ADDITIONAL_SUPPORTED_CHECKS}" CACHE STRING
foreach(CHECK IN LISTS ADDITIONAL_CHECK_TYPES) foreach(CHECK IN LISTS ADDITIONAL_CHECK_TYPES)
if(NOT CHECK IN_LIST ADDITIONAL_SUPPORTED_CHECKS) if(NOT CHECK IN_LIST ADDITIONAL_SUPPORTED_CHECKS)
message(SEND_ERROR "'${CHECK}' is not a supported check type") message(FATAL_ERROR "'${CHECK}' is not a supported check type")
endif() endif()
endforeach() endforeach()
@ -322,7 +322,7 @@ foreach(MF IN LISTS MATCH_FINDERS)
string(TOUPPER "${MF}" MF_UPPER) string(TOUPPER "${MF}" MF_UPPER)
add_compile_definitions("HAVE_MF_${MF_UPPER}") add_compile_definitions("HAVE_MF_${MF_UPPER}")
else() else()
message(SEND_ERROR "'${MF}' is not a supported match finder") message(FATAL_ERROR "'${MF}' is not a supported match finder")
endif() endif()
endforeach() endforeach()
@ -356,7 +356,7 @@ set_property(CACHE ENABLE_THREADS
set(USE_WIN95_THREADS OFF) set(USE_WIN95_THREADS OFF)
if(NOT ENABLE_THREADS IN_LIST SUPPORTED_THREAD_METHODS) if(NOT ENABLE_THREADS IN_LIST SUPPORTED_THREAD_METHODS)
message(SEND_ERROR "'${ENABLE_THREADS}' is not a supported thread type") message(FATAL_ERROR "'${ENABLE_THREADS}' is not a supported thread type")
endif() endif()
if(ENABLE_THREADS) if(ENABLE_THREADS)
@ -448,13 +448,13 @@ set(ENCODERS "${SUPPORTED_FILTERS}" CACHE STRING "Encoders to support")
# If LZMA2 is enabled, then LZMA1 must also be enabled. # If LZMA2 is enabled, then LZMA1 must also be enabled.
if(NOT "lzma1" IN_LIST ENCODERS AND "lzma2" IN_LIST ENCODERS) if(NOT "lzma1" IN_LIST ENCODERS AND "lzma2" IN_LIST ENCODERS)
message(SEND_ERROR "LZMA2 encoder requires that LZMA1 is also enabled") message(FATAL_ERROR "LZMA2 encoder requires that LZMA1 is also enabled")
endif() endif()
# If LZMA1 is enabled, then at least one match finder must be enabled. # If LZMA1 is enabled, then at least one match finder must be enabled.
if(MATCH_FINDERS STREQUAL "" AND "lzma1" IN_LIST ENCODERS) if(MATCH_FINDERS STREQUAL "" AND "lzma1" IN_LIST ENCODERS)
message(SEND_ERROR "At least 1 match finder is required for an " message(FATAL_ERROR "At least 1 match finder is required for an "
"LZ-based encoder") "LZ-based encoder")
endif() endif()
set(HAVE_DELTA_CODER OFF) set(HAVE_DELTA_CODER OFF)
@ -472,7 +472,7 @@ foreach(ENCODER IN LISTS ENCODERS)
string(TOUPPER "${ENCODER}" ENCODER_UPPER) string(TOUPPER "${ENCODER}" ENCODER_UPPER)
add_compile_definitions("HAVE_ENCODER_${ENCODER_UPPER}") add_compile_definitions("HAVE_ENCODER_${ENCODER_UPPER}")
else() else()
message(SEND_ERROR "'${ENCODER}' is not a supported encoder") message(FATAL_ERROR "'${ENCODER}' is not a supported encoder")
endif() endif()
endforeach() endforeach()
@ -574,7 +574,7 @@ foreach(DECODER IN LISTS DECODERS)
string(TOUPPER "${DECODER}" DECODER_UPPER) string(TOUPPER "${DECODER}" DECODER_UPPER)
add_compile_definitions("HAVE_DECODER_${DECODER_UPPER}") add_compile_definitions("HAVE_DECODER_${DECODER_UPPER}")
else() else()
message(SEND_ERROR "'${DECODER}' is not a supported decoder") message(FATAL_ERROR "'${DECODER}' is not a supported decoder")
endif() endif()
endforeach() endforeach()
@ -689,8 +689,8 @@ option(MICROLZMA_DECODER
if(MICROLZMA_ENCODER) if(MICROLZMA_ENCODER)
if(NOT "lzma1" IN_LIST ENCODERS) if(NOT "lzma1" IN_LIST ENCODERS)
message(SEND_ERROR "The LZMA1 encoder is required to support the " message(FATAL_ERROR "The LZMA1 encoder is required to support the "
"MicroLZMA encoder") "MicroLZMA encoder")
endif() endif()
target_sources(liblzma PRIVATE src/liblzma/common/microlzma_encoder.c) target_sources(liblzma PRIVATE src/liblzma/common/microlzma_encoder.c)
@ -698,8 +698,8 @@ endif()
if(MICROLZMA_DECODER) if(MICROLZMA_DECODER)
if(NOT "lzma1" IN_LIST DECODERS) if(NOT "lzma1" IN_LIST DECODERS)
message(SEND_ERROR "The LZMA1 decoder is required to support the " message(FATAL_ERROR "The LZMA1 decoder is required to support the "
"MicroLZMA decoder") "MicroLZMA decoder")
endif() endif()
target_sources(liblzma PRIVATE src/liblzma/common/microlzma_decoder.c) target_sources(liblzma PRIVATE src/liblzma/common/microlzma_decoder.c)
@ -715,8 +715,8 @@ option(LZIP_DECODER "Support lzip decoder" ON)
if(LZIP_DECODER) if(LZIP_DECODER)
# If lzip decoder support is requested, make sure LZMA1 decoder is enabled. # If lzip decoder support is requested, make sure LZMA1 decoder is enabled.
if(NOT "lzma1" IN_LIST DECODERS) if(NOT "lzma1" IN_LIST DECODERS)
message(SEND_ERROR "The LZMA1 decoder is required to support the " message(FATAL_ERROR "The LZMA1 decoder is required to support the "
"lzip decoder") "lzip decoder")
endif() endif()
add_compile_definitions(HAVE_LZIP_DECODER) add_compile_definitions(HAVE_LZIP_DECODER)