To help you manage project dependencies and external libraries, CLion integrates with vcpkg, a package manager for C/C++.
Select Vcpkg tool window.from the main menu to open the
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
Click Ok and wait for the installation to complete.
The list of packages will appear in the middle pane. In the right-hand pane, you can find the description and actions for the selected package.
Browse and install packages
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.
In classic mode, if the package was installed successfully, CLion will prompt you to add it to vcpkg.json and switch to manifest mode:
You can find the installed package under Installed | Classic Mode or Added | Manifest Mode.
Switch to manifest mode
Click the Switch to Manifest Mode button:
Select the packages to be added to vcpkg.json:
CLion will create a vcpkg.json file, add the packages, and switch the project to manifest mode:
Investigate console output
Console: vcpkg is a read-only tab that shows all vcpkg commands with full output.
When errors occur, for example, during package installation, CLion shows a notification message. Click Show output to open the Console tab and investigate the problem.
You can switch to the Console tab at any time while working with vcpkg. The tab is also accessible via the Show Console button.
Install/remove multiple packages
Select several packages in the tree.
Use the following shortcuts:
To install or add to vcpkg.json, press Enter.
To remove, press Alt+Delete / ⌘⌫.
Start using a package
Packages should be added to CMakeLists.txt. For most packages, vcpkg provides the code to be included in CMake script.
If there is a hint from vcpkg, you will see the Add packages to CMakeLists.txt option in the notification:
Copy the suggested code into your CMakeLists.txt file. If required, change the target link name (which is
mainby default) to the one you want the packages to be linked to.
Update vcpkg and packages
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.
Click on the toolbar and select Auto-update repositories on IDE restart to allow CLion to check for repository updates on each IDE restart.
Use quick-fixes to add missing packages
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:
Force the use of system CMake and Ninja
Click the Edit vcpkg button in the left-hand pane:
Expand the Advanced Settings section and set the Use system binaries checkbox: