Vcpkg: How to build package for mulitple versions of Visual Studio / multiple toolsets?

Created on 1 Jun 2017  ·  10Comments  ·  Source: microsoft/vcpkg

Is it possible to build e.g. boost for multiple toolsets (140 and 141) with vcpkg?

(If 140 and 141 is a bad example because they are compatible, think of 141 and 150)

Perhaps the triplet could be expanded to include toolset as well (with empty toolset => latest being the default)?

vcpkg-feature

Most helpful comment

I would suggest to create a triplet (e.g. x64-windows-v140) with the content of x64-windows and additionally the line

VCPKG_PLATFORM_TOOLSET=v140

and a second one (e.g. x64-windows-v141) with

VCPKG_PLATFORM_TOOLSET=v141

Then you can use

vcpkg install boost:x64-windows-v140 boost:x64-windows-v141

to build boost with both, VS2015 and VS2017.

Some additional remarks regarding the pull request: Since the PR is work in progress and tries to solve a more complicated problem (Fortran support) I am not sure when it will be ready to be merged. Maybe it makes sense to extract the changes that allow setting a toolset version explicitly into an other PR which can be merged without that much effect on other parts. @ras0219-msft what do you think?

All 10 comments

The merge request #1098 adds support for pretty much exactly what you want as a side effect to supporting Fortran.

You can specify the toolset version via VCPKG_PLATFORM_TOOLSET in the triplet. If it is empty, vcpkg will do as it does now and just takes the latest VS version it can find.

Wow, that's great!

Could you clarify with an example of compiling a package foo for both vs2015 and vs2017 (when the feature is merged)?

I would suggest to create a triplet (e.g. x64-windows-v140) with the content of x64-windows and additionally the line

VCPKG_PLATFORM_TOOLSET=v140

and a second one (e.g. x64-windows-v141) with

VCPKG_PLATFORM_TOOLSET=v141

Then you can use

vcpkg install boost:x64-windows-v140 boost:x64-windows-v141

to build boost with both, VS2015 and VS2017.

Some additional remarks regarding the pull request: Since the PR is work in progress and tries to solve a more complicated problem (Fortran support) I am not sure when it will be ready to be merged. Maybe it makes sense to extract the changes that allow setting a toolset version explicitly into an other PR which can be merged without that much effect on other parts. @ras0219-msft what do you think?

I totally agree with splitting the fortran PR into two separate PRs! It has been a bit since I looked at the code changes, but I recall the toolset option support being pretty much good to go.

The triplet suggestion is also exactly as I would recommend handling the toolset difference (though the exact syntax would be set(VCPKG_PLATFORM_TOOLSET v140)).

We'll get an explosion of triplets sooner or later ;). Each feature that's added to them doubles the number of potential "triplets". And toolset is binary only atm.

Yep, there's an explosion of _possible_ triplets. This is just the wonderful/terrible nature of the beast that is C++!

However, that doesn't mean we must add all of them by default! It's important to be capable of handling these scenarios, but it's also important to clearly indicate where the path ends and the forest begins!
🌲 🌲 🌲

For this specific case, we'll continue with what we do today: pick the latest of VS2015 or VS2017. In some future where there's another abi break, we'll need to add a new set of triplets for that.

простите, а вынести в командную строку можно данный параметр?
или это возможно только вносить через скрипт cmake

Sorry, but the command line can be put in this option?
or is it only possible to make cmake via script

C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140PlatformsWin32PlatformToolsets>dir

LLVM-vs2014
LLVM-vs2014_xp
v140
v140_clang_3_7
v140_clang_c2
v140_xp
WindowsApplicationForDrivers10.0
WindowsKernelModeDriver10.0
WindowsUserModeDriver10.0

простите, а вынести в командную строку можно данный параметр?
или это возможно только вносить через скрипт cmake

@Voskrese I'm not totally sure what you mean by that, but many of those toolsets are slightly different MSBuild wrappers around a small set of true compiler versions (which may have different default compiler macros/flags).

We've recently added support for specifying compiler flags in the triplet file via https://github.com/Microsoft/vcpkg/commit/0c70ca21940f48e4129b677af544b52379b3c232, which may help here.

As for using clang, we don't currently support it though we'd be open to PR's that make it work! The trouble would be figuring out how to pipe it through into all the various library buildsystems. Most might react to a CXX environment variable.

ras0219-msft, спасибо за ответ, я уже понял) только для версии 14 и 15 полностью совместимы
не судите строго, из-за незнания много вещей)

ras0219-msft, thanks for the reply, I have already realized) only version 14 and 15 are fully compatible
do not judge strictly, due to ignorance of many things)

I have tried the triplets to install x86 toolset 141 boost libs and I'm not having much success.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grandprixgp picture grandprixgp  ·  3Comments

invy picture invy  ·  3Comments

F0I0l0I0P picture F0I0l0I0P  ·  3Comments

jack17529 picture jack17529  ·  3Comments

madkoala picture madkoala  ·  3Comments