How to enable static linking using vcpkg

(from https://gist.github.com/cenit/469d0c2ccbf428614fc35de443470929)

While vcpkg works without any problem and any modification for the default triplet (x86-windows), if you need to use vcpkg libraries in your project targeting different triplets a small manual tag addition is required.

Open the project' .vcxproj file and find this section:

<PropertyGroup Label="Globals">
        ....
</PropertyGroup>

Inside this section, please add these tags (at the end of the PropertyGroup is perfect), depending on the choosen triplet:

x86-windows-static

    <VcpkgTriplet>x86-windows-static</VcpkgTriplet>
    <VcpkgEnabled>true</VcpkgEnabled>

x64-windows

    <VcpkgTriplet>x64-windows</VcpkgTriplet>
    <VcpkgEnabled>true</VcpkgEnabled>

x64-windows-static

    <VcpkgTriplet>x64-windows-static</VcpkgTriplet>
    <VcpkgEnabled>true</VcpkgEnabled>

Posted in c++, vcpkg on Aug 31, 2018