How to provide modules in extra-cmake-modules ?

Michael Jansen kde at michael-jansen.biz
Sun Jul 10 19:21:49 CEST 2011


On Sunday 10 July 2011 19:02:44 Alexander Neundorf wrote:
> Hi,
> 
> when somebody will use e-c-m, he will do a
> 
> find_package(extra-cmake-modules)
> 
> 
> What should that do except finding the location where they are ?
> 
> 1) It could change CMAKE_MODULE_PATH.
> I think I'm not in favour of this. In general, such a call should not modify
> the settings, but just provide variables etc. We did that with
> FindKDE4Internal.cmake and I'm not too happy about it.
> 
> 2) It could set a ECM_MODULE_DIR variable, which points to the modules/
> directory of e-c-m.
> Then the user is free to do
> set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_DIR})
> or not.
> 
> 3) We could recommend to use
> include(${ECM_MODULE_PATH}/ECMOptionalAddSubdirectory.cmake)
> 
> 
> I think I'm in favour of option 2).
> 
> Related to that, if a user adds this directory to his CMAKE_MODULE_PATH,
> should we provide two directories ?
> One for modules which override modules which are present in cmake, and
> another one (modules/) which adds modules which are not present in cmake.
> But maybe then we also have to handle this differently for different cmake
> versions, some modules might make it into a later cmake version...

The config manager in me goes nuts and just finishes your thoughts to the 
extreme case.

Provide two variable (whatever name they will have)

ECM_MODULE_PATH
==============
ecm additions. this var is naturally unaffected from the used cmake version 
apart from the provided module beeing version agnostic or fail if the cmake 
version is to old. The path would look like that.
<ECM_PREFIX>/cmake/modules/ecm/

ECM_CMAKE_MODULES_PATH
====================
ecm cmake patches or however you want to call that. The path would be 
something like this:
<ECM_PREFIX>/cmake/modules/cmake-<CMAKE_VERSION>/
We set that var according to the used cmake version. That method has the 
charm/problem that we would have to review that modules with each new cmake 
version and copy over those that are still needed. In case someone uses a new 
version we not yet have reviewed he could not use ecm (yet). We could allow 
that use case with a big red warning like (unsupported cmake version x.y. we 
give you that modules of cmake version x.y-1).

The real charm would be that we could remove support for old cmake version 
quite easily. Just remove their directory.

The real problem would be that we have to support backwards compatibility. Say 
a developer develops stuff which cmake 2.7 and ecm. He uses some of our cmake 
overriding modules. He must be sure that if someone uses cmake 2.6 it still 
compiles if he wants to support that cmake version. So perhaps we have to 
define a cmake version range we support.

Another chance we have is to change a cmake file when copying it for a new 
cmake version to make it use some new cmake feature therefore keeping them 
more easily up to date.

Mike





> 
> Alex
> _______________________________________________
> Kde-buildsystem mailing list
> Kde-buildsystem at kde.org
> https://mail.kde.org/mailman/listinfo/kde-buildsystem


More information about the Kde-buildsystem mailing list