Vcpkg: Add pkg-config like options

Created on 27 Jan 2018  Β·  2Comments  Β·  Source: microsoft/vcpkg

pkg-config --cflags --libs somepackage on a Linux distribution would return compiler flags and linker options for linking with an installed library, allowing pretty much any build system to find those and link.

vcpkg seems to only support CMake as an alternative build system. If something analogous to pkg-config was created, providing locations of libraries, include directories, and MSVC flags, other build systems could be made aware of libraries installed using vcpkg.

Obviously, MSVC flags would have to be distributed with the package.

vcpkg-feature

Most helpful comment

@purell That's quite interesting – I didn't know vcpkg supported pkg-config. It would be nice to at least see this being somewhat integrated with vcpkg, however, i.e., such that it can be assumed that as long as vcpkg is installed and detected, libraries and their linker options can be located using such a command or its extended vcpkg counterpart.

All 2 comments

I played a little bit with vcpkg+pkg-config-lite+meson so I will resume my experience...

Some package like protobuf install pkg-config file and produce the *.pc file required by pkg-config program to find library.

Ex :

D:.
β”œβ”€β”€β”€vcpkg
└───x86-windows
    β”œβ”€β”€β”€bin
    β”‚       libprotobuf-lite.dll
    β”‚       libprotobuf-lite.pdb
    β”‚       libprotobuf.dll
    β”‚       libprotobuf.pdb
    β”‚       libprotoc.dll
    β”‚       libprotoc.pdb
    β”‚
    β”œβ”€β”€β”€lib
    β”‚   β”‚   libprotobuf-lite.lib
    β”‚   β”‚   libprotobuf.lib
    β”‚   β”‚   libprotoc.lib
    β”‚   β”‚
    β”‚   └───pkgconfig
    β”‚           protobuf-lite.pc
    β”‚           protobuf.pc

Install and configure vc-pkg

> D:\
> git clone https://github.com/Microsoft/vcpkg.git
> cd vcpkg
> .\bootstrap-vcpkg.bat
> .\vcpkg integrate install
> .\vcpkg install zlib libsodium protobuf

Now install pkg-config-lite and configure it.

> set PKG_CONFIG_PATH=%PKG_CONFIG_PATH%;D:\Data\vcpkg\packages\protobuf_x86-windows\lib\pkgconfig

Use meson to build a c++ program that link to protobuf

project('myprogram', 'cpp', version : '1.0')

src = ['main.cpp'] 

protobuf = dependency('protobuf', version: '>=3.0')

executable('myprogram',
           sources: src,
           dependencies: [protobuf])

This work perfectly as pkg-config-lite find the libprotobuf.pc file by looking at the %PKG_CONFIG_PATH% path.

But what if we want to use library like zlib or libsodium both are not configured to produce a pkg-config file.

See ref here : https://github.com/mesonbuild/meson/issues/4029#issuecomment-416952360

I think vc-pkg should always produce or offer options to produce pkg-config file.

@purell That's quite interesting – I didn't know vcpkg supported pkg-config. It would be nice to at least see this being somewhat integrated with vcpkg, however, i.e., such that it can be assumed that as long as vcpkg is installed and detected, libraries and their linker options can be located using such a command or its extended vcpkg counterpart.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spindensity picture spindensity  Β·  3Comments

cskrisz picture cskrisz  Β·  3Comments

pkeir picture pkeir  Β·  3Comments

cjvaijo picture cjvaijo  Β·  3Comments

F0I0l0I0P picture F0I0l0I0P  Β·  3Comments