Re: [cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?
On Tuesday 06 December 2011, Alexander Neundorf wrote: Hi, On Monday 07 November 2011, Brad King wrote: On 11/6/2011 6:12 AM, Stephen Kelly wrote: 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. See below for an idea that may solve cases 2 and 3 together. 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() We've done the following before: if(EXISTS ${CMAKE_ROOT}/Modules/FindBlub.cmake) include(${CMAKE_ROOT}/Modules/FindBlub.cmake) return() endif() That way you don't need to know when the module is added. It is also forward-compatible for any module not yet in CMake but may be later. OTOH the version of the module added to CMake may provide a slightly different interface than the original version. That leads to the unfortunate situation that a newer CMake breaks an existing build, which looks like CMake's fault but isn't. Another option is to provide a function that generates forwarding modules. Instead of ecm_copy_modules, create a similar API that generates short modules that include either the ECM version or the CMake version depending on some conditions. Do the inclusion by full path so that the actual ECM module dir does not need to be in the CMAKE_MODULE_PATH. yesterday in the train I found the time to do start with something on this. So, here is the idea: * the files containing macros/functions and the find-modules are put into two different directories, e.g. modules/macros/ and modules/find/. (Since the macros will all have the ecm_ prefix, a clash with anything from cmake is not possible. So we only have to care about the Find-modules.) So when doing find_package(extra-cmake-modules) two variables will be defined, ECM_MACROS_DIR and ECM_FIND_MODULES_DIR. If somebody wants everything, he does set(CMAKE_MODULES_PATH ${ECM_MACROS_DIR} ${ECM_FIND_MODULES_DIR} ) If he wants to use only some macros, he does set(CMAKE_MODULES_PATH ${ECM_MACROS_DIR} ) If he wants to use a subset of the find-modules, there is a function ecm_use_find_modules: ecm_use_find_modules(DIR destdir MODULES FindFoo.cmake FindBar.cmake ... [NO_OVERRIDE] ) The listed find-modules will be copied from ${ECM_FIND_MODULES_DIR} to the directory given here as destination dir, and this directory has to be added to CMAKE_MODULE_PATH. If NO_OVERRIDE is used, the files will only be used if they do not exist in cmake. This way e.g. FindBlub.cmake will be used until it is part of cmake, then the cmake version will be used. Attached is a draft of the file, just to show the idea, I didn't actually try to run it yet. Examples: 1) use everything from e-c-m: find_package(extra-cmake-modules REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MACROS_DIR} ${ECM_FIND_MODULES_DIR} ) 2) make all macros available, but no find-modules: find_package(extra-cmake-modules REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MACROS_DIR} ) 3) make all macros available and some find-modules if they do not yet exist in cmake: find_package(extra-cmake-modules REQUIRED) ecm_use_find_modules(DIR ${CMAKE_CURRENT_BINARY_DIR}/ecm/ MODULES FindFoo.cmake NO_OVERRIDE) set(CMAKE_MODULE_PATH ${ECM_MACROS_DIR} ${CMAKE_CURRENT_BINARY_DIR}/ecm/ ) 4) make all macros available and some find-modules as override for the cmake ones: find_package(extra-cmake-modules REQUIRED) ecm_use_find_modules(DIR ${CMAKE_CURRENT_BINARY_DIR}/ecm/ MODULES FindBoost.cmake) set(CMAKE_MODULE_PATH ${ECM_MACROS_DIR} ${CMAKE_CURRENT_BINARY_DIR}/ecm/ ) Does that look like it should cover all use cases, for peopling wanting to selectively use some things from e-c-m, and fearing that something would break if they simply would make everything available ? I added this now to extra-cmake-modules: http://quickgit.kde.org/?p=extra-cmake- modules.gita=blobhb=HEADf=modules/ECMUseFindModules.cmake The find-modules now go into find-modules/, other modules go into modules/. Alx -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe:
Re: [cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?
On 12/6/2011 1:13 PM, Alexander Neundorf wrote: Does that look like it should cover all use cases, for peopling wanting to selectively use some things from e-c-m, and fearing that something would break if they simply would make everything available ? That proposal looks good to me. As an additional suggestion, I think you should always use an ECM version number so people get used to writing it. That way projects can ensure they get a compatible version of ECM: find_package(extra-cmake-modules 1.2 REQUIRED) -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?
On Tuesday 06 December 2011, Brad King wrote: On 12/6/2011 1:13 PM, Alexander Neundorf wrote: Does that look like it should cover all use cases, for peopling wanting to selectively use some things from e-c-m, and fearing that something would break if they simply would make everything available ? That proposal looks good to me. As an additional suggestion, I think you should always use an ECM version number so people get used to writing it. That way projects can ensure they get a compatible version of ECM: find_package(extra-cmake-modules 1.2 REQUIRED) Do you mean the version number should be enforced ? Alex -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?
On 12/6/2011 1:37 PM, Alexander Neundorf wrote: On Tuesday 06 December 2011, Brad King wrote: That proposal looks good to me. As an additional suggestion, I think you should always use an ECM version number so people get used to writing it. That way projects can ensure they get a compatible version of ECM: find_package(extra-cmake-modules 1.2 REQUIRED) Do you mean the version number should be enforced ? Not necessarily, but it is good practice especially in this case. -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] Fwd: How to handle different cmake versions in extra-cmake-modules ?
On 11/6/2011 6:12 AM, Stephen Kelly wrote: 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. See below for an idea that may solve cases 2 and 3 together. 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() We've done the following before: if(EXISTS ${CMAKE_ROOT}/Modules/FindBlub.cmake) include(${CMAKE_ROOT}/Modules/FindBlub.cmake) return() endif() That way you don't need to know when the module is added. It is also forward-compatible for any module not yet in CMake but may be later. OTOH the version of the module added to CMake may provide a slightly different interface than the original version. That leads to the unfortunate situation that a newer CMake breaks an existing build, which looks like CMake's fault but isn't. Another option is to provide a function that generates forwarding modules. Instead of ecm_copy_modules, create a similar API that generates short modules that include either the ECM version or the CMake version depending on some conditions. Do the inclusion by full path so that the actual ECM module dir does not need to be in the CMAKE_MODULE_PATH. -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers