这篇文章上次修改于 387 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

Curl作为基础工具,字编译后使用cmake在其他项目中引用。

1. curl编译安装

Curl编译下载自Github仓库
使用Cmake生成Visual Studio 工程文件编译安装到C:\Program Files (x86)\CURL 下。

2. 其他项目使用Find_Package()使用

使用前需要先设置部分变量,CMAKE才能够自动寻找的上面的CURL。

CURL_ROOT="C:/Program Files (x86)/CURL"
CURL_NO_CURL_CMAKE=TRUE
CMAKE_POLICY_DEFAULT_CMP0074=NEW

cmake-gui中配置示例:
cmake-curl.png

3. 参考

CMake文档

New in version 3.17.

If CURL was built using the CMake buildsystem then it provides its own <span class="pre">CURLConfig.cmake</span> file for use with the <span class="pre">find_package()</span> command's config mode. This module looks for this file and, if found, returns its results with no further action.

Set <span class="pre"><span class="highlighted">CURL_NO_CURL_CMAKE</span></span> to <span class="pre">ON</span> to disable this search.