[cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?

Stephen Kelly steveire at gmail.com
Sun Nov 6 06:12:15 EST 2011


Re-sending.

-------- Original Message --------
Subject: 	How to handle different cmake versions in extra-cmake-modules ?
Date: 	Sat, 5 Nov 2011 16:45:44 +0100
From: 	Alexander Neundorf <neundorf at kde.org>
Reply-To: 	neundorf at kde.org
To: 	cmake-developers at cmake.org
CC: 	Stephen Kelly <steveire at gmail.com>



Hi,

we (in KDE) are working on setting up a package/project "extra-cmake-modules"
which will provide additional cmake modules for other cmake-using projects,
mostly find-modules.

I don't really have a plan yet how to handle different cmake versions, etc.

I see at least the following three cases:

1) we may include modules, which do not exist in cmake.

2) we may include modules, which differ from versions in cmake. Using projects
should be able to decide whether they want to use the version from cmake or
from e-c-m on a file-by-file basis.

3) we may include modules, which do not exist in cmake up to some version, but
then they were added to cmake. Users of such a newer cmake version should get
the version from cmake.


I assume that a directory which contains the modules from e-c-m is added to
CMAKE_MODULE_PATH, something like:

find_package(extra-cmake-modules REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}  ${ECM_MODULE_DIRECTORY} )

Case 1 is simple. The using project uses the module or not.



Case 2 is not so simple. One idea I have is to have the using project specify
explicitely which files they need, e.g. something like

find_package(extra-cmake-modules REQUIRED)

ecm_copy_modules(${CMAKE_BINARY_DIR}/modules FindFoo.cmake
                                              FindBlub.cmake
                                              ECMDoSomething.cmake)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}  ${CMAKE_BINARY_DIR}/modules} )

This macro would copy just these needed files into the given directory, which
can then be added to CMAKE_MODULE_PATH.



Case 3. I don't really have an idea yet. Add some code at the top of each file
which include()s the file from cmake if the version is bigger than some
specified version ?

Something like:
FindBlub.cmake:

if(CMAKE_VERSION>  2.8.12)
   include(${CMAKE_ROOT}/Modules/FindBlub.cmake)
   return()
endif()


Ideas, comments, etc. ?

Thanks
Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20111106/85b8008e/attachment.html>


More information about the cmake-developers mailing list