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