overriding CMAKE_MODULE_PATH

Alexander Neundorf neundorf at kde.org
Mon Aug 16 21:09:46 CEST 2010


Hi,

On Monday 16 August 2010, you wrote:
> Am 15.08.2010 20:28, schrieb Alexander Neundorf:
> > On Sunday 15 August 2010, Yury G. Kudryashov wrote:
> >> Hi!
> >>
> >> Many (all?) KDE modules have the following string in the beginning of
> >> CMakeLists.txt:
> >>
> >> set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
> >>
> >> What do you think about replacing this string with the following?
> >>
> >> set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules
> >> ${CMAKE_MODULE_PATH})
> >>
> >> This would allow user to say, e.g.,
> >>
> >> cmake ${kdenetowrk_src_dir} -
> >> DCMAKE_MODULE_PATH=${libktorrent_prefix}/share/apps/cmake/modules
> >
> > Why would you want to do that ?
>
> Because it is the right thing to do. The first line overriding it is
> just plain wrong imho.
>
> 1. CMAKE_MODULE_PATH is documented in cmake at the same level as
> CMAKE_PREFIX_PATH as a variable that changes behaviour. Which means a
> user can and will expect he is able to override it. Which will break
> with the first line.
>
> 2. KDE installs a ton of useful not kde related FindXYZ*.cmake files
> into a path != /usr/share/cmake... . If a non kde project wants to use
> it (even a small homegrown project) the user has to set
> CMAKE_MODULE_PATH from the outside. 

No.
It either needs to find KDE4 (find_package(KDE4)), since using any of the 
files which are installed together with kdelibs means you are depending on 
KDE4.

OR

he needs to copy the files he needs into its own project.

> Therefore he needs the line from 
> Yury in his CMakeLists.txt. Since we as kde are the poster child for
> cmake usage we should implement our cmake files as examples for other to
> copy.

Yes.
Unfortunately installing find-modules (as we de in kdelibs) is actually not 
that good example.
Once I figured that out I tried to make sure that kdelibs and I think 
kdepimlibs stay the only modules which do that.

> 3. If someone develops a small lib he plans to add as a kde dependency
> he probably installs it into some non distro prefix so he doesn't need
> root rights to install it. So he needs to override CMAKE_MODULE_PATH in
> say koffice to make it pick up that location.

No.
I don't understand. 
There is no need to override CMAKE_MODULE_PATH.
If he installs libfoo to $HOME/my/installs/ then all he needs to do so others 
can find it is to $ export CMAKE_PREFIX_PATH=$HOME/my/installs:
$CMAKE_PREFIX_PATH

Alex


More information about the Kde-buildsystem mailing list