Check whether CMake was built with zstd support
CMake 3.18 introduced the file(ARCHIVE_CREATE) API that we use with COMPRESSION Zstd for compressing corelib's mimedatabase. It's possible to build CMake without proper zstd support, and we have encountered such builds in the wild where the file(ARCHIVE_CREATE) call crashes. Add a configure test to determine whether CMake properly supports the Zstd compression method. Fixes: QTBUG-89108 Change-Id: I37e389c878845162b6f18457984d4f73a265b604 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
5656a60dd0
commit
f4417bf7e8
5
config.tests/cmake_zstd/check_zstd.cmake
Normal file
5
config.tests/cmake_zstd/check_zstd.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
file(ARCHIVE_CREATE
|
||||
OUTPUT cmake_zstd.zstd
|
||||
PATHS "${CMAKE_CURRENT_LIST_FILE}"
|
||||
FORMAT raw
|
||||
COMPRESSION Zstd)
|
@ -830,6 +830,24 @@ qt_feature("zstd" PRIVATE
|
||||
LABEL "Zstandard support"
|
||||
CONDITION ZSTD_FOUND
|
||||
)
|
||||
# special case begin
|
||||
# Check whether CMake was built with zstd support.
|
||||
# See https://gitlab.kitware.com/cmake/cmake/-/issues/21552
|
||||
if(NOT DEFINED CACHE{QT_CMAKE_ZSTD_SUPPORT})
|
||||
set(QT_CMAKE_ZSTD_SUPPORT FALSE CACHE INTERNAL "")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/config.tests/cmake_zstd/check_zstd.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/config.tests"
|
||||
OUTPUT_QUIET ERROR_QUIET
|
||||
RESULT_VARIABLE qt_check_zstd_exit_code)
|
||||
if(qt_check_zstd_exit_code EQUAL 0)
|
||||
set(QT_CMAKE_ZSTD_SUPPORT TRUE CACHE INTERNAL "")
|
||||
endif()
|
||||
unset(qt_check_zstd_exit_code)
|
||||
endif()
|
||||
endif()
|
||||
# special case end
|
||||
qt_feature("thread" PUBLIC
|
||||
SECTION "Kernel"
|
||||
LABEL "Thread support"
|
||||
|
@ -1187,6 +1187,11 @@ if(QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database)
|
||||
)
|
||||
else()
|
||||
if(QT_FEATURE_zstd)
|
||||
if(NOT QT_CMAKE_ZSTD_SUPPORT)
|
||||
message(FATAL_ERROR
|
||||
"CMake was not built with zstd support. "
|
||||
"Rebuild CMake or set QT_AVOID_CMAKE_ARCHIVING_API=ON.")
|
||||
endif()
|
||||
set(qmime_db_compression Zstd)
|
||||
string(APPEND qmime_db_content "#define MIME_DATABASE_IS_ZSTD\n")
|
||||
else()
|
||||
|
Loading…
x
Reference in New Issue
Block a user