windows10下编译zlib库

系列文章目录

前言

我使用CMake编译zlib源码,出现警告:CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.

Update the VERSION argument value or use a … suffix to tell
CMake that the project does not need compatibility with older versions.
下载zlib源码:

在这里插入图片描述
找到:
在这里插入图片描述

一、问题原因

这个警告表明,你的项目中的CMakeLists.txt文件使用了一个过时的CMake最低版本要求。为了解决这个问题,你需要更新CMakeLists.txt中的cmake_minimum_required命令,将最低版本要求设置为2.8.12或更高版本。同时,如果你的项目不需要与旧版本CMake保持兼容,可以添加一个最大版本要求。

你可以这样修改CMakeLists.txt文件中的cmake_minimum_required命令:

cmake_minimum_required(VERSION 2.8.12...<max>)

将替换为你想要指定的最大兼容版本。例如,如果你想要兼容最高到CMake 3.19,可以这样写:

cmake_minimum_required(VERSION 2.8.12...3.19)

二、准备

zlib:A Massively Spiffy Yet Delicately Unobtrusive Compression Library
(Also Free, Not to Mention Unencumbered by Patents)
(Not Related to the Linux zlibc Compressing File-I/O Library)
翻译:一个非常漂亮但又不显眼的压缩库 (也是免费的,更不用说不受专利保护了) (与 Linux zlibc 压缩文件-I/O 库无关)

目前版本
Version 1.2.13 has these key updates from 1.2.12:

Fix a bug when getting a gzip header extra field with inflateGetHeader(). This remedies CVE-2022-37434.
Fix a bug in block type selection when Z_FIXED used. Now the smallest block type is selected, for better compression.
Fix a configure issue that discarded the provided CC definition.
Correct incorrect inputs provided to the CRC functions. This mitigates a bug in Java.
Repair prototypes and exporting of the new CRC functions.
Fix inflateBack to detect invalid input with distances too far.
Due to the first bug fix, any installations of 1.2.12 or earlier should be replaced with 1.2.13.
Version 1.2.12 has these key improvements over 1.2.11:

Fix a deflate bug when using the Z_FIXED strategy that can result in out-of-bound accesses.
Fix a deflate bug when the window is full in deflate_stored().
Speed up CRC-32 computations by a factor of 1.5 to 3.
Use the hardware CRC-32 instruction on ARMv8 processors.
Speed up crc32_combine() with powers of x tables.
Add crc32_combine_gen() and crc32_combine_op() for fast combines.
You can also look at the complete Change Log.

翻译:版本 1.2.13 从 1.2.12 开始有以下关键更新:修复了使用 inflateGetHeader() 获取 gzip 标头额外字段时的错误。 这可补救 CVE-2022-37434。 修复了使用 Z_FIXED 时块类型选择中的错误。 现在选择最小的块类型,以便更好地压缩。 修复丢弃提供的 CC 定义的配置问题。 更正提供给 CRC 功能的不正确输入。 这减轻了 Java 中的错误。 修复原型并导出新的 CRC 函数。 修复 inflateBack 以检测距离太远的无效输入。 由于第一个错误修复,任何 1.2.12 或更早版本的安装都应替换为 1.2.13。 版本 1.2.12 相对于 1.2.11 有以下主要改进: 修复了使用 Z_FIXED 策略时可能导致越界访问的 deflate 错误。 修复 deflate_stored() 中窗口已满时的放气错误。 将 CRC-32 计算速度提高 1.5 到 3 倍。在 ARMv8 处理器上使用硬件 CRC-32 指令。 使用 x 表的幂加速 crc32_combine()。 添加 crc32_combine_gen() 和 crc32_combine_op() 以实现快速组合。 您还可以查看完整的更改日志。

具体操作

或者修改成:cmake_minimum_required(VERSION 2.8.12)
在这里插入图片描述
这样,当使用更新的CMake版本编译zlib源码时,不再出现关于CMake版本的警告信息。
在这里插入图片描述
在这里插入图片描述

编译zlib工程

在这里插入图片描述
在这里插入图片描述
release版
在这里插入图片描述
debug
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/aoxuestudy/article/details/130034701