[CMake] [RFC] How to use pkg-config under Windows (... and OSX)?

Hendrik Sattler post at hendrik-sattler.de
Thu Nov 17 15:38:20 EST 2011


Am Donnerstag, 17. November 2011, 18:26:08 schrieb Alexander Neundorf:
> Let's say package Foo (unrelated to KDE, and unrelated to cmake) has been
> ported from UNIX to Windows, and installs a pkgconfig file.
> This pkgconfig file is generated at the time when the binary package for
> Foo is generated.
> 
> Now a user downloads and installs the binary package of Foo, along with the
> included pkgconfig file, which contains the install path from build time.
> But the user can now decide where he will install this binary package.
> This may differ from what is recorded in the pkgconfig file in the binary
> package of Foo.
> So the Foo.pc file is installed, and contains e.g. "C:/Foo/include", but
> the user decides to install it to "D:/MyStuff/", so the include dir would
> be "D:/MyStuff/include".
> 
> 
> Now cmake comes into play.
> Let's say there is a project Bar, which uses Foo, so it does
> find_package(Foo).
> 
> Now FindFoo.cmake uses pkgconfig:
> 
> find_package(PkgConfig)
> pkg_check_modules(Foo ...)
> 
> Now this will report C:/Foo/include (because this is what the
> pkgconfig-file contains), instead of D:/MyStuff/include, where the user
> decided to install it.

No. Pkg-config should derive the prefix variable from the location of the .pc 
file. According to documentation, it does this on Windows, so it should report 
D:/MyStuff/include

HS


More information about the CMake mailing list