[cmake] use CMake's provided FindBZip2
github:
@@ -725,8 +725,16 @@ else()
endif()
if(WITH_BZIP)
- check_include_files(bzlib.h HAVE_BZLIB_H)
- check_library_exists(bz2 BZ2_bzCompress "" HAVE_LIBBZ2)
+ find_package(BZip2)
+ if(BZIP2_FOUND)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
+ set(BZIP_LIBRARY BZip2::BZip2)
+ else()
+ set(BZIP_LIBRARY ${BZIP2_LIBRARIES})
+ endif()
+ set(HAVE_BZLIB_H TRUE)
+ set(HAVE_LIBBZ2 TRUE)
+ endif()
else()
unset(HAVE_BZLIB_H)
unset(HAVE_LIBBZ2)
@@ -1087,7 +1095,7 @@ if(HAVE_ZLIB_H OR HAVE_ZSTD_H OR HAVE_BZLIB_H OR HAVE_BROTLI OR HAVE_LIBDEFLATE)
set(L_MOD_DEFLATE ${L_MOD_DEFLATE} zstd)
endif()
if(HAVE_BZLIB_H)
- set(L_MOD_DEFLATE ${L_MOD_DEFLATE} bz2)
+ set(L_MOD_DEFLATE ${L_MOD_DEFLATE} ${BZIP_LIBRARY})
endif()
if(HAVE_BROTLI)
set(L_MOD_DEFLATE ${L_MOD_DEFLATE} brotlienc)
