automoc4 from kdesupport now supported for building KDE

David Faure faure at kde.org
Wed Jun 4 13:35:30 CEST 2008


On Tuesday 03 June 2008, Brad King wrote:
> David Faure wrote:
> > On Tuesday 03 June 2008, Brad King wrote:
> >> The issue here is that we (cmake devs) view the PATHS argument as a list
> >> of last resort paths (e.g. hard-coding c:/Python25), not preferred
> >> paths.  There are a whole bunch of user-controlled places that are
> >> searched before /usr/lib.
> > 
> > This assumes that users specify all their lib locations as arguments. It's nice to be able
> > to do that, but ideally things should just "work out of the box", that's the whole point
> > of that list of paths -- to try and autodetect where the stuff is installed, to save the
> > user some work.
> 
> The motivation behind our view is that users should be able to set
> CMAKE_PREFIX_PATH and have CMake find things there first. 

Sure, that's fine and that's what I want too :)

> Currently the 
> only way to override what the NO_DEFAULT_PATH stuff finds is to set the
> result variable in the cache by hand for each and every library.  If you
> (as a project dev) want to look in a set of default locations on the
> users' behalf, they should be added to the search path variables by the
> project.  Then none of the find_* commands needs special arguments, only
> one call to each is needed, and users can override things easily.

But that means modifying global variables, i.e. affecting all other calls to find_library?
This doesn't sound right. When looking for libbz2 we surely don't want to look into 
${KDE4_LIB_INSTALL_DIR} ${KDE4_LIB_DIR} ${QT_LIBRARY_DIR} ...

> >> If you have variables like KDE4_LIB_INSTALL_DIR that are supposed to
> >> tell you where to find the library, why do you need to search for it in
> >> default paths at all?
> > 
> > Because those are just hints. Maybe phonon is in the kde install dir, but maybe it has
> > been installed into its own prefix instead. In the first case it should be autodetected,
> > while in the latter case it's normal that the user has to specify a prefix -- but that doesn't
> > work because of NO_DEFAULT_PATH (which is only there so that the autodetection
> > prefers KDE4_LIB_INSTALL_DIR over /usr/lib, not to prevent users from setting the right
> > path manually!).
> 
> Okay, so follow the above advice:
> 
>   find_package(FOO REQUIRED)
> 
>   # Foo tells me where I might find other stuff.
>   list(APPEND CMAKE_PREFIX_PATH ${FOO_INSTALL_PREFIX})
> 
>   find_library(BAR_LIBRARY NAMES bar)
>   # tada!  BAR_LIBRARY is found under <foo-prefix>/lib

Yes. However this means not using NO_DEFAULT_PATH, so this brings up this orthogonal issue:

Imagine I have a /usr/lib/libphonon.so from kubuntu (so it's old, and was compiled in release mode),
and I compile my own libphonon.so into my own prefix (say /opt/phonon/lib/libphonon.so or whatever).
IIRC a call to find_library() would prefer the one in /usr/lib/libphonon.so even when doing
find_library(PHONON_LIBRARY NAMES phonon PATHS /opt/phonon/lib)
because the system paths are checked first (right? I hope I don't remember wrongly).
This is the reason why we're using NO_DEFAULT_PATH everywhere -- but I agree, it's a workaround.
Ideally we shouldn't have to use it. And then setting CMAKE_PREFIX_PATH or cmake-2.4 similar vars would work.

Right Alex? This is the reason for the NO_DEFAULT_PATH in FindPhonon? Or is the reason
rather that you wanted CMAKE_SYSTEM_LIBRARY_PATH to have more priority than qt's [old] phonon?
(but that's a tough choice, they could both be too old :)

Removing NO_DEFAULT_PATH fixes my problem (phonon is found when setting CMAKE_PREFIX_PATH correctly)
OK about this patch, Alex?

--- FindPhonon.cmake    (revision 816378)
+++ FindPhonon.cmake    (working copy)
@@ -17,9 +17,9 @@ else(PHONON_FOUND)
       set(PHONON_FIND_QUIETLY TRUE)
    endif(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)

-   find_library(PHONON_LIBRARY NAMES phonon PATHS ${KDE4_LIB_INSTALL_DIR} ${KDE4_LIB_DIR} ${CMAKE_SYSTEM_LIBRARY_PATH} ${QT_LIBRARY_DIR} ${LIB_INSTALL_DIR} NO_DEFAULT_PATH)
+   find_library(PHONON_LIBRARY NAMES phonon PATHS ${KDE4_LIB_INSTALL_DIR} ${KDE4_LIB_DIR} ${CMAKE_SYSTEM_LIBRARY_PATH} ${QT_LIBRARY_DIR} ${LIB_INSTALL_DIR})

-   find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h PATHS ${KDE4_INCLUDE_INSTALL_DIR} ${KDE4_INCLUDE_DIR} ${CMAKE_SYSTEM_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} NO_DEFAULT_PATH)
+   find_path(PHONON_INCLUDE_DIR NAMES phonon/phonon_export.h PATHS ${KDE4_INCLUDE_INSTALL_DIR} ${KDE4_INCLUDE_DIR} ${CMAKE_SYSTEM_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR})

    if(PHONON_INCLUDE_DIR AND PHONON_LIBRARY)
       set(PHONON_LIBS ${phonon_LIB_DEPENDS} ${PHONON_LIBRARY})

(although I think  ${CMAKE_SYSTEM_LIBRARY_PATH} can be removed too)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).


More information about the Kde-buildsystem mailing list