Vscode-cmake-tools: Unable to use vcpkg

Created on 1 Jun 2018  路  8Comments  路  Source: microsoft/vscode-cmake-tools

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

configure bug more info needed

Most helpful comment

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

All 8 comments

Hi! Sorry for the slow response. I've been facing some hardware trouble at home and haven't been able to work on this project as much as I'd like.

The next release will include some tweaks the Kits that will help support more toolchain file magic. Until then, try setting CMAKE_TOOLCHAIN_FILE via cmake.configureSettings instead? It may or may not work, but I'd be interested to see. Prefer to use cmake.configureSettings for setting options via -D (see the docs for more details).

If this doesn't help, follow up and I'll continue helping look into this.

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. :)

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

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

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

This is very frustrating that you cannot use the Microsoft package manager with the Microsoft cmake plugin.

Adding "CMAKE_PREFIX_PATH": "PATH TO VCPKG FOR PLATFORM" Did get me up and working. Would be nice if it supported the CMAKE_TOOLCHAIN_FILE. If anyone is looking for a complete example, ended up in this ticket, and has docker installed I made a minimal starter project with sqlite being installed from vcpkg,

https://github.com/camccar/cppCmakeVcpkgRemoteContainer

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

Was this page helpful?
0 / 5 - 0 ratings