[CMake] pkg-config question

Alexander Neundorf a.neundorf-work at gmx.net
Fri Jul 24 16:23:24 EDT 2009


On Thursday 23 July 2009, Varga Levente wrote:
> Hello!
>
> Could somebody direct me to or send me an example on how to use the
> pkg-config finder in cmake. I recently started using cmake as builder
> tool for my projects and I cannot figure out how to make pkg-config work
>  with cmake. I read the documentation and it's very clear, but in spite
> of this I cannot make it work. I doing something wrong but in lack of an
> example I cannot figure out what. Thank you!

First recommendation: don't use pkg-config, it only brings trouble ;-). 
Are you sure you really need it ?

Second recommendation: Here's an example how to use it:
http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/FindLibXml2.cmake?revision=938476&view=markup
The "QUIET" keyword is a KDE extension, don't use it.
I think also the if(NOT WIN32) guard around it is not necessary, but I can't 
test it here.
Beside that, use the macro to get some information, if you don't get anything, 
try to find the package the standard cmake way, if you get information, use 
that information as HINT for the FIND_XXX() calls, since only then you will 
get the variables properly filled with the full path.
Also make sure you don't use the same names for the variables created by the 
PKG_CHECK_MODULES() macro as for the FIND_XXX() calls, since then you will 
get unwanted effects (the FIND_XXX() calls will do nothing since the 
variables are already set to something valid, but usually not the full path).
That's why in KDE it is recommended to use the "PC_" prefix for the variables 
from pkgconfig.

Alex


More information about the CMake mailing list