Vscode-cmake-tools: Vcpkg and Kits don't mix well

Created on 3 Mar 2018  路  2Comments  路  Source: microsoft/vscode-cmake-tools

Brief Issue Summary

The current design of Kits don't mix well with Vcpkg, an invaluable tool for Windows OSS developers. It's practically a package manager written in CMake. I recently started using it and went straight to contributing 3 packages into it.

The problem is, that Vcpkg _abuses_ toolchain files for dependencies only, but not the compiler itself. Because Kits rightfully expect a compiler to be defined when using toolchain kits, it chokes on vcpkg.cmake, because it does not define a compiler, but just about everything else.

Expected:

I would like CMake Tools to allow toolchain files to be specified in any of the Kit types.

Strange workaround:

I though of going for the Visual Studio 15 2017 Win64 generator to implicitly find the compiler when using Vcpkg. However, using this generator it chokes saying

The Platform for project 'VCTargetsPath.vcxproj' is invalid.  Platform=' Win64'.

By changing the generator to Visual Studio 15 2017Win64 it works as expected, it's just CMake Tools that throws an error that it doesn't know this generator, otherwise it works.

Platform and Versions

  • Operating System: Windows
  • CMake Version: 3.10.0
  • VSCode Version: 1.19.0
  • CMake Tools Extension Version: 0.11-beta4
  • Compiler/Toolchain: Visual C++ 2017
Feature Request

Most helpful comment

It worked like a charm! Awesome! Thanks for the tip. For others (future reference):

[
  {
    "name": "MSVC 15.6-beta5",
    "visualStudio": "a2f9235f",
    "visualStudioArchitecture": "amd64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64"
    },
    "cmakeSettings": {
      "CMAKE_TOOLCHAIN_FILE": "C:/Users/mnagy/Source/Repos/vcpkg/scripts/buildsystems/vcpkg.cmake"
    }
  }
]

All 2 comments

Looks like a bad regex in driver.ts grabs the space before Win64 in the full generator name.

Here's a possible better workaround, and maybe a bit easier to support: You can set arbitrary CMake settings in a kit with the cmakeSettings key. Try adding CMAKE_TOOLCHAIN_FILE there?

It worked like a charm! Awesome! Thanks for the tip. For others (future reference):

[
  {
    "name": "MSVC 15.6-beta5",
    "visualStudio": "a2f9235f",
    "visualStudioArchitecture": "amd64",
    "preferredGenerator": {
      "name": "Visual Studio 15 2017",
      "platform": "x64"
    },
    "cmakeSettings": {
      "CMAKE_TOOLCHAIN_FILE": "C:/Users/mnagy/Source/Repos/vcpkg/scripts/buildsystems/vcpkg.cmake"
    }
  }
]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

andschwa picture andschwa  路  6Comments

gabyx picture gabyx  路  5Comments

j-m picture j-m  路  5Comments

decimad picture decimad  路  6Comments

OleksandrKvl picture OleksandrKvl  路  3Comments