KDE/kdelibs/cmake/modules

Alexander Neundorf neundorf at kde.org
Thu Feb 16 21:28:08 CET 2006


On Thursday 16 February 2006 20:29, you wrote:
> On Thursday 16 February 2006 19:59, Alexander Neundorf wrote:
> > I think we have three options:
> > -rename addressbook.cc
>
> Of course. But this won't be the only place where foo/bar.h and blah/bar.h
> exist, so better find a solution at the build system level.
> This is also why I don't really want to use custom-build-rules solutions
> either.
>
> On the other hand the current source layout makes little sense (libkab.la
> is only used for kab2kabc), so my fix includes moving kab2kabc to the kab
> subdir, to compile the program entirely from there.
>
> > I think relying on the order of include dirs would suck.
>
> Hmm, just when I finally got it to work ;-)
>
> First with the KDE4Macros.cmake patch which I committed and then reverted,
> to create foo/bar.moc from foo/bar.h (I think this makes sense, no?).

I wouldn't do this. Just using CMAKE_CURRENT_BINARY_DIR is ok. We only can get 
this problem if there are several source files which have the same basename 
compiled to a target in the same directory. This is in itself not very 
favorable I think.

> But it means include_directories fixes for several places in kdelibs, due
> to that.
>
> And finally in kabc the fix is attached. Tell me what you think.

That's obviously the best and simplest solution :-)

> I think include_directories( BEFORE ${CMAKE_CURRENT_SOURCE_DIR}
> ${CMAKE_CURRENT_BINARY_DIR} ) is something that would make sense in every
> cmakelist (-> macro needed). When you write #include "foo.h" in a file, you

The am2cmake script which created all the CMakeLists.txt put the following on 
top of each file:

kde4_header()

This is currently an empty macro, intended to do the stuff which should be 
done for every CMakeLists.txt, if we find that there is something which we 
need in every CMakeLists.txt.
So now we could have it do something:

macro(KDE4_HEADER)
 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )
endmacro(KDE4_HEADER)

or, as Brad suggested, slightly extended:

macro(kde4_include_directories)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR})
   foreach(d ${ARGV})
# add some handling to work both with absolute and relative paths
      include_directories(${CMAKE_CURRENT_BINARY_DIR}/${d})
      include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${d})
   endforeach(d)
endmacro(kde4_include_directories)

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