KdePimlibs overriding CMAKE_MODULE_PATH

Alexander Neundorf neundorf at kde.org
Mon Jun 15 20:08:14 CEST 2009

On Sunday 07 June 2009, Alex Merry wrote:
> In KdepimLibsConfig.cmake.in, which is used to generate a file included
> when you do find_package(KdepibLibs), the KdepimLibs cmake module directory
> (typically the same as the KDE cmake module directory) is added to the
> If an application/module/whatever sets its CMAKE_MODULE_PATH to something
> local before calling find_package(KdepibLibs), as kdenetwork does for
> example, the local cmake module directory is overridden by the installed
> KDE one.  This leads to things like the wrong
> FindLibKNotificationItem-1.cmake file being included by KGet, and the
> kdenetwork build failing.
> My question: is the correct solution to change KdepimLibsConfig.cmake.in to
> append (rather than prepend) its directory to CMAKE_MODULE_PATH?  

If kdepimlibs would append its module path to CMAKE_MODULE_PATH, it would not 
be possible to override e.g. cmake modules installed by kdelibs from 

In kdenetwork/CMakeLists.txt there is 
set(CMAKE_MODULE_PATH  ${CMAKE_SOURCE_DIR}/cmake/modules )

and later on it does 

After that the modules from KdepimLibs will be found before the ones from 

This may be not what one would expect.

Some general notes:
-modifying CMAKE_MODULE_PATH is only necessary for installed cmake modules
-every installed cmake module (at least from kdelibs) has to be kept 
compatible at least until the end of KDE4, 
-so in general, we shouldn't install too many such modules
-more specifically, if possible, modules beside kdelibs should not install 
such cmake modules, but kdepimlibs is also a "libs" module, so it is somewhat 
-kdepimlibs installs only 5 cmake modules, do you really get some conflict 
there ?

So what do we do ?
Changing the order can be a source incompatible change, but it could also be 
interpreted as a bug fix. But if we append it instead of prepend it, we can 
never be sure that we actually get the cmake modules we want.

Maybe CMAKE_MODULE_PATH shouldn't be modified at all and 
find_package(KdepimLibs) should just set a KDEPIMLIBS_MODULE_DIR variable, and 
the user has to use this to set CMAKE_MODULE_PATH ?
This would lead to the rule that the only cmake module in KDE svn which 
modifies CMAKE_MODULE_PATH is FindKDE4Internal.cmake, i.e. 
This would indead be a source incompatible change, and as such actually not 
possible at all. 
But at least right now there are not that many modules which do that, so maybe 
this could be the last chance before we go with a maybe bad policy into the 
longer KDE4 series...

Comments ?


More information about the Kde-buildsystem mailing list