# Conan 插件

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/clion/llms.txt).

> **TL;DR**
> 插件  ： [Conan](https://plugins.jetbrains.com/plugin/11956-conan)（未捆绑）
>
>
>
> Conan 版本  ：2.0.5 或更高版本
>
>
>
> 项目格式  ：CMake
>
>
>
> CMake 版本  ：3.24 或更高版本

[JFrog](https://jfrog.com) 提供的 Conan 插件允许您在 CLion 中使用 Conan（一个 C/C++ 包管理器）。 该插件通过 [依赖提供程序](https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#dependency-providers) [cmake-conan](https://github.com/conan-io/cmake-conan/tree/develop2) 将 Conan 与 CMake 集成。 此依赖提供程序将 CMake 配置转换为 Conan。

Procedure: 安装 Conan

1. 请按照官方 [安装指南](https://docs.conan.io/1/installation.html) 在您的系统上安装 Conan。

Procedure: 安装 Conan 插件

1. 转到  `设置 | 插件` 。

2. 找到   Conan   插件。

![从 CLion 安装 Conan 插件](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_plugininstall.png)

3. 请点击   安装。

4. 在打开的对话框中，点击   接受  ：

![接受安装第三方插件](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_accepthirdpartyplugin.png)

5. 重启 CLion。

Procedure: 配置插件

1. 从主菜单中选择  `查看 | 工具窗口 | Conan`  或点击 Conan 图标以打开插件工具窗口：

![Conan 工具窗口图标](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_twicon.png)

2. 点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.settings.svg)。

3. ![Conan 插件设置](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_settings.png)

* 提供 Conan 客户端可执行文件的路径，或选中 使用系统中已安装的 Conan 复选框以使用系统级安装的版本。

* 在 为以下配置使用 Conan 部分中，设置或清除与 [CMake 配置文件](cmake-profile.html) 对应的复选框。

* 自动为所有配置添加 Conan 支持 选项默认启用：插件将为新配置文件添加 Conan 支持。

* 最后一个复选框也默认启用，允许 Conan 顺序运行 CMake，而不是并行运行。 这是必要的，因为直到 Conan 2.0.9 版本，Conan 缓存都不支持并发。

4. 点击   确定  。

> **Note:**
> 您将在 CMake 输出中看到一条警告，指示  `find_package()`  命令未添加到  `CMakeLists.txt` 。 这些命令稍后会被添加，因此您可以安全地忽略此警告。

Procedure: 将库添加到您的项目

1. 在搜索字段中开始输入库名称，并从结果列表中选择：

![搜索库](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_searchresult.png)

2. 选择库版本并点击   在项目中使用  ：

![将库添加到项目](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_useinprj_button.png)

3. 点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.general.inspections.inspectionsEye.svg)。

![浏览已添加的库](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_explorelibs_dialog.png)

此对话框显示已添加到项目中的所有库，以及基本目标信息和要添加到 CMake 的代码段。

> **Tip:**
> Conan 将有关已使用包的信息存储在项目文件夹中的  `conandata.yml`  文件中。 此文件由  `conanfile.py`  读取。 可以自定义这些文件，以实现插件的高级用法。

4. 根据说明将命令添加到  `CMakeLists.txt` 。 例如：

```CMAKE
find_package(CURL)
target_link_libraries(calendar_run CURL::libcurl)

```

5. 点击编辑器中的 CMake 重新加载图标或选择  `工具 | CMake | 重新加载 CMake 项目` 。

![重新加载 CMake 项目](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_reloadproject.png)

> **Note:**
> 库会在 CMake 配置步骤中安装。

在 CMake 配置完成后，您可以像往常一样 [构建](build-actions.html) 和 [运行](running-applications.html) / [调试](debugging-code.html) 您的应用程序。

Procedure: 更新包

1. 点击 ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.refresh.svg) 以在   Conan   工具窗口中更新软件包和依赖提供程序：

![更新包](https://resources.jetbrains.com/help/img/idea/2026.3/cl_conan_updatedependencies.png)

## See also

### 操作指南

[vcpkg integration](package-management.html)

### 教程

[快速 CMake 教程](quick-cmake-tutorial.html)

### 外部链接

[CLion blog: Introducing the New CLion Conan Plugin](https://blog.jetbrains.com/clion/2023/09/introducing-the-new-clion-conan-plugin/)

