vscode-cmake-tools: Unable to use vcpkg

Hello,

I am trying to use vcpkg on Ubuntu with vscode. After I install the vcpkg, did the bootstrap and run sudo ./vcpkg integrate install. The console output:

Applied user-wide integration for this vcpkg root.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/path_of_vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake"

Then, I install a library vckpg install cppzmq. The console output is:

...
The package cppzmq:x64-linux provides CMake targets:

    find_package(cppzmq CONFIG REQUIRED)
    target_link_libraries(main PRIVATE cppzmq libzmq cppzmq-static libzmq-static)

Based on the first output, i edited the vscode user settings file settings.json by adding following entry:

"cmake.configureArgs": [
        "-DCMAKE_TOOLCHAIN_FILE=/path_of_vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake"
    ]

After build, I got error:

[cmake] CMake Error at CMakeLists.txt:169 (find_package):
[cmake]   Could not find a package configuration file provided by "cppzmq" with any
[cmake]   of the following names:
[cmake] 
[cmake]     cppzmqConfig.cmake
[cmake]     cppzmq-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "cppzmq" to CMAKE_PREFIX_PATH or set
[cmake]   "cppzmq_DIR" to a directory containing one of the above files.  If "cppzmq"
[cmake]   provides a separate development package or SDK, be sure it has been
[cmake]   installed.
[cmake] 
[cmake] 
[cmake] Configuring incomplete, errors occurred!
[cmake] See also "/home/rong/projects/SGX/code/MajordomoServer/build/CMakeFiles/CMakeOutput.log".
[cms-driver] Error during CMake configure: [cmake-server] Configuration failed.

After a bit search, I can see a file ‘cppzmqConfig.cmake’ is in path_of_vcpkg/vcpkg/buildtrees/cppzmq/x64-linux-dbg/cppzmqConfig.cmake, So I tried to edit settings.json

"cmake.configureArgs": [
        "-DCMAKE_TOOLCHAIN_FILE=/path_of_vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake",
        "-DCMAKE_PREFIX_PATH=path_of_vcpkg/vcpkg/buildtrees/cppzmq/x64-linux-dbg/cppzmqConfig.cmake"
    ]

But the same error still pops up.

Based on https://docs.microsoft.com/en-us/cpp/vcpkg, The only thing I need is adding “-DCMAKE_TOOLCHAIN_FILE” when configuring ‘cmake’. Any suggestions about how to configure CMAKE_TOOLCHAIN_FILE correctly by using CMake Tools plugin?

Environment: Ubuntu 16.04 LTS VSCode 1.23.1 VSCode plugin CMake Tools 0.11.1 VSCode plugin CMake 0.0.17 CMake version: 3.11.1 Clang 7.0 vcpkg 0.0.113

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 13
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Is this solved? i have the same problem using cmake and vcpkg and vscode on windows.

nvm, just adding include(<vcpkg location>/vcpkg/scripts/buildsystems/vcpkg.cmake) makes it all work without using CMAKE_PREFIX_PATH

Thanks for you reply VOB. You are definitely a OpenGL fan, aren’t you? I tried to use the vcpkg without vs code. Just manually config CMake by using ccmake .. -DCMAKE_TOOLCHAIN_FILE=path_of_config_file.cmake in a build folder. It is not working. (More details in the link https://github.com/Microsoft/vcpkg/issues/3655). I think I will wait for suggestions or a fix for that issue before trying other things. Thanks again. 😃

When is this fixed? I looked all over the web and tried lots of different triplets because I thought I keep getting the wrong one. Even though I see people suggesting ways to make it work, it should’ve worked without those workarounds in the first place.

CMAKE_TOOLCHAIN_FILE still does not work, but this is working in my setup: "CMAKE_PREFIX_PATH": "path_to_vcpkg/installed/x86-windows"

No, we did not have the chance to look at this issue yet.