How to use vcpkg with clion?


It seems vcpkg is a very simple to use solution for incorporation c++ libraries.

How can you use it in combination with clion?


I've been trying to figure out how to incorporate external libraries in my project for a while now, but it seems every other existing method is library specific.

Comment actions Permalink

Hi, Yoav!

Just in case: in general external libraries should be included into a project using find_package and target_link_libraries CMake commands. We have a tutorial in our web help (here).

Comment actions Permalink

but vcpkg also installs the library and all its dependencies automatically...


In any case, I looked at the help page you linked to and tried to use the boost-assert library based on the information there.

I get the following error message:

"C:\Program Files\JetBrains\CLion 2017.2.3\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug5 -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" "C:\Users\yoavpol.WISMAIN\Dropbox\PhD\A - Project - C++\Codes\MD Box Clion"
CMake Error at C:/vcpkg/vcpkg-master/scripts/buildsystems/vcpkg.cmake:53 (message):
Unable to determine target architecture.
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2017.2.3/bin/cmake/share/cmake-3.8/Modules/CMakeDetermineSystem.cmake:88 (include)
CMakeLists.txt:2 (project)

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!


Would really appreciate some help with this. I'm starting to consider switching to Visual C++ just for the simple inclusion of libraries via  vcpkg.

Comment actions Permalink

Could you please describe in more details what you've done? 

In order to use Boost in your CMake project you need to have Boost libraries installed and to add smth similar to the following in your CMakeLists.txt:

IF (Boost_FOUND)
target_link_libraries (my_target ${Boost_LIBRARIES})
Comment actions Permalink

Hello Anna,

I would like to bring an answer to Yoav's question, and raise a related one, which seems to be more complex.

How to use VCPKG with CLion

What Yoav tried to say is this: VCPKG provides a .cmake file to be used during configuration process, so that CMake can correctly recognize the needed libraries' paths. A good advice of its usage with CLion's cmake was found here ( ):

  1. Go to File -> Settings -> Build, Execution, Deployment -> CMake
  2. Choose one profile, and then find "CMake Options".
  3. Insert value to the option: -DCMAKE_TOOLCHAIN_FILE=<path_to_vcpkg>/scripts/buildsystems/vcpkg.cmake

A no-usability case for VCPKG in CLion

However, when I use the aforementioned setup, the automatic configuration step which parses the CMakeLists.txt freezes at the point of "checking the working C compiler":

"C:\Program Files\CMake\bin\cmake.exe"
-G "CodeBlocks - NMake Makefiles" D:\<my-project>

-- The C compiler identification is MSVC 19.14.26431.0
-- The CXX compiler identification is MSVC 19.14.26431.0
-- Check for working C compiler: C:/Program Files (x86)/
Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe

This does not progress; it does not un-freeze even after some time. It seems stuck on some parsing sub-routine.

To be clear, we speak here of the following configuration:

  1. Windows 7 x64
  2. Microsoft Visual Studio 2017 Build Tools
  3. cmake 3.* (either I use bundled version, 3.10 / 3.12, or the independently installed one, 3.11 - it is still the same problem)

My project uses many libraries, managed by VCPKG, and the toolchain "CMake+VCPKG+MSVC" runs very well outside of CLion. Therefore, this seems to be a problem of a toolchain "CLion+VCPKG+MSVC" (hence the warning "experimental support" :) )

Comment actions Permalink

@Viachaslau, thanks a lot for the clarification!

Unfortunately, I didn't managed to reproduce the issue on my side (CLion 2018.2.4, Windows 10, MSVC toolchain, bundled CMake). I installed vcpkg, installed Boost using it, added -DCMAKE_TOOLCHAIN_FILE=<path_to_vcpkg>/scripts/buildsystems/vcpkg.cmake to the CMake profile (File -> Settings -> Build, Execution, Deployment -> CMake), added lines about Boost to my CMakeLists.txt and the CMake project was loaded successfully: 

Do you have any threadDump* folders in the logs folder (Help | Show Log in ...)? If yes, please send them to clion-support at

Comment actions Permalink

In case of this message, or any similar issue that makes it look that vcpkg is not being used at all, vcpkg will list the underlying issue in vcpkg-manifest-install-out.log and/or vcpkg-manifest-install-err.log.

In my case, 9/10 times it was something wrong with the portfile or my vcpkg.json manifest file. 

Comment actions Permalink

Anna Falevskaya

If I set "CMake options" as follows -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake

the $HOME variable is not recognized and results in

Could not find toolchain file: $HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
Call Stack (most recent call first):


It's ricidulous I can't use $HOME variable. Is there any workaround except pasting the full path?

Comment actions Permalink

El unfortunately, for now it's not possible to use environment variables in CMake options. Feel free to comment or upvote See if you are not familiar with YouTrack.

Comment actions Permalink

Anna Falevskaya you must be kidding! It's a shame variables are not supported!

Comment actions Permalink

I don't see what the big deal is about not using the "$HOME" variable... do people not know their own home directory? if you have to go in and copy/paste a directory path for something to work.. then it's not much more work to just add a few extra letters to your line..


I think it works beautifully.. Ty JB team and Kitware team for making this process so much easier. and scalable

Comment actions Permalink

I had to change to VSC cuz twas easier .. geez


Please sign in to leave a comment.