KDE/kdelibs/cmake/modules

Alexander Neundorf neundorf at kde.org
Sat Jan 6 17:45:40 CET 2007


On Tuesday 02 January 2007 22:54, Thiago Macieira wrote:
> Alexander Neundorf wrote:
> >> UsePkgConfig. It shouldn't use --variable=includedir.
> >
> >Isn't it a bug in the pkgconfig files if it doesn't report the required
> >include dirs for variable=includedir ?
>
> Not really. I don't think it's mandatory. Even if it is, I have no idea
> how one should hardcode multiple include dirs -- which seems to be the
> case here and in D-Bus.
>
> >Can you please have a look at FindPkgConfig.cmake from current cmake cvs
> > ? It does a lot more than the UsePkgConfig.cmake we currently have.
>
> http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/UsePkgConfig.cmake?rev=1.5
>&root=CMake is exactly the same as my version here.
>
> But I've just realised that the cflags are there. We just are using the
> wrong thing. Drop the includedir stuff: use cflags only.

No, do not use the --cflags output for adding the include dirs !
This breaks cmake's include dir handling.
Because then you do
add_definitions(${FOO_CFLAGS})

with FOO_CFLAGS being "-I/usr/include/foo -D_enable_foo" or something like 
this.
When doing it this way, cmake does not know that /usr/include/foo is one of 
the include directories. But it has to know (at least it should know), 
because among others it uses this information to sort the include dirs so 
that the in-project-include-dirs come before the out-of-project-include-dirs. 
If cmake can't do this, gcc can find the wrong headers and thus the build can 
be broken.

With include(UsePkgConfig)
the best way should be this:
PKGCONFIG(qca _Qca2IncDir _Qca2LinkDir _Qca2LinkFlags _Qca2Cflags)
FIND_PATH(QCA2_INCLUDE_DIR QtCrypto 
          PATHS ${_Qca2IncDir} <more paths you want to check...>   
          NO_DEFAULT_PATH)
FIND_PATH(QCA2_INCLUDE_DIR QtCrypto )

This way at first the dir returned from pkgconfig is searched and if there's 
nothing found then in the second call to FIND_PATH() the default directories 
are searched.

Current cmake cvs features a FindPkgConfig.cmake, which is much more advanced 
than the simple UsePkgConfig.cmake I wrote.
With this new one we get a QCA_INCLUDE_DIRS variable which does exactly what 
we want, it asks pkgconfig for all includedirs and puts them nicely into a 
cmake list of directories which can be used with include_directories().
I guess I'll add this one to kdelibs/cmake/modules/ until we require cmake 
2.4.6.

Bye
Alex
-- 
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org                - http://www.kde.org
      alex AT neundorf.net               - http://www.neundorf.net


More information about the Kde-buildsystem mailing list