Manage packages
To help you manage project dependencies and external libraries, CLion integrates with vcpkg, a package manager for C/C++.
note
Current limitations:
Supported toolchains are all except for Windows Cygwin, WSL, Docker, and Remote.
vcpkg registries are not yet supported.
See Known issues for the corresponding tickets in CLion tracker.
tip
Vcpkg will be installed on your system. You can have multiple instances of vcpkg installed, each with a different set of packages.
Also, you can have multiple projects linked to one vcpkg repository.
Select View | Tool Windows | Vcpkg from the main menu to open the Vcpkg tool window.
Click
:
Specify the installation settings in the Add Vcpkg dialog:
The name and URL of your vcpkg repository.
The installation directory (or use the default value). If you already have vcpkg installed, provide the path to its location in this field.
Add vcpkg integration to existing CMake profiles
CLion uses CMake toolchain file to integrate with vcpkg. Select the CMake profiles you want the toolchain file to be linked to.
After the installation, you can find the toolchain file added to the selected profile's CMake options via the
CMAKE_TOOLCHAIN_FILE
variable.
Click Ok and wait for the installation to complete.
After installation, the list of packages appears in the middle pane. The right-hand pane shows details of the selected package.
note
The option to select a particular version is not implemented yet (CPP-32366). Only the latest package version can be installed.
To find a particular package, start typing its name in the search field:
Select the package and press Enter or click Install in the right-hand pane.
tip
If any errors occur during installation, you can investigate them using detailed console output. Click Show output in the notification message to view it.
You can find the installed package in the Installed subtree:
To install several packages at a time, select them in the tree and press Enter or click Install in the right-hand pane:
To remove multiple packages, select them in the tree and press Alt+Delete / ⌘⌫ or scroll down the list in the right-pand pane and click Delete:
Packages can be automatically added to vcpkg.json in the project root, or you can add them manually.
tip
Using vcpkg.json implies switching to manifest mode.
Click
on the toolbar and select vcpkg.json auto-change to enable CLion to update vcpkg.json automatically:
When vcpkg.json auto-change is disabled, you can still use the Actions menu in notifications that appear after package installation:
Packages should be added the CMakeLists.txt script.
Select Add packages to CMakeLists.txt in the notification menu:
Copy the suggested code into your CMakeLists.txt file. If required, change the target link name (which is
main
by default) to the one you want the packages to be linked to.
Use the following tool window actions for update and upgrade:
Update All updates the vcpkg Git repository to the latest version and then checks it for available package updates.
Upgrade All updates the vcpkg Git repository to the latest version and then updates all installed packages to their latest versions.
Check for Updates (the
menu) checks whether there is a newer version of the vcpkg Git repository.
Update Repository (the
menu) checks the current version of the vcpkg Git repository for available package updates.
Upgrade Repository (the
menu) checks the current version of the vcpkg Git repository for available package updates and installs them.
Update Vcpkg Repository (the
menu) updates the vcpkg Git repository to the latest version.
Packages that can be upgraded are indicated with a warning sign.
Select a package and click the Upgrade package icon in the right-hand pane:
Click
on the toolbar and select Auto-update repositories on IDE restart to allow CLion to check for repository updates on each IDE restart.
If you include a header from a package that is not yet installed, compilation will fail with the file not found error. Click Fix next to the error message:
CLion will suggest to install the missing package:
In case there are multiple candidates for installation, open the list from the Fix menu:
Select the package to install in the dialog:
A similar quick-fix is provided for CMake scripts. You can find the Fix link in the CMake tool window:
tip
Fix also works for the profiles not linked to the package manager.
tip
Another package manager you can use in CLion is Conan, which works via a third-party Conan plugin (maintained by JFRog). The plugin is not actively developed at the moment.
Thanks for your feedback!