[cmake-developers] Could a cmake_maximum_required() work?

Stephen Kelly steveire at gmail.com
Wed Apr 25 14:17:19 EDT 2012


Brad King wrote:

> On Wed, Apr 25, 2012 at 1:55 PM, Stephen Kelly
> <steveire at gmail.com> wrote:
>> The idea is that if you use cmake_maximum_required(2.8.8) and attempt to
>> use a feature or API introduced in 2.8.9, CMake would report an error.
> 
> I don't think that's the opposite of a minimum required version, I
> think that *is* one. 

I'm having trouble parsing this. What does 'It is one' mean?

> The same error could be generated just from
> 
>   cmake_minimum_required(VERSION 2.8.8)

You mean we could make using this command also set the maximum version to 
allow use of API from?

> 
> because CMake 2.8.9 would know that it is possible users may run 2.8.8
> on the project.
> 
> Either way it will be very difficult to implement and maintain.  

I'm not certain it would be hard to implement, but yes, it would be an 
increased maintenance burden. 

I'm kind of interested in it though, so maybe I'll do a test-patch between 
2.8.8 so we can do a real evaluation.

> Even
> if we taught every feature to check the version projects might do
> 
>  if(NOT ${CMAKE_VERSION} VERSION_LESS 2.8.9)
>   # use 2.8.9 feature
>  endif()
> 
> and it would be very hard for CMake code running inside the condition
> to detect that it is okay.

Yes, I don't think cases like that would not be possible to handle fully. 
This issue came up because KDE wants to ensure that developers do not 
accidentally use features of newer versions of CMake. 

Given that, if someone in KDE wants to use an if() conditional on CMake 
version, the feature would either have to be implemented another way, or the 
minimum CMake version would need to be increased. (ie, I would propose 
dealing with the issue by dis-allowing it, which may not work for all 
projects indeed).


> Project testing infrastructure (e.g. nightly dashboard builds) should
> include runs using the oldest CMake allowed to ensure things work
> without newer features.

Yes, that is the current most likely solution.

Thanks,

Steve.






More information about the cmake-developers mailing list