[CMake] Re: General modernization facility

Rodolfo Schulz de Lima rodolfo at rodsoft.org
Tue Dec 18 15:31:28 EST 2007


Brandon Van Every wrote:

> Let's say really old code does cmake_minimum_required(VERSION 2.2.0
> FATAL_ERROR).  CMake 2.6.0 meets that minimum requirement.  It should
> run the old code correctly, unless there's a really really good reason
> to break backwards compatibility.  CMake 2.6.0 isn't going to have
> CMAKE_REQUIRE_BOOL, or any such newfangled change, as default
> behavior.  It would break old code.  cmake_minimum_required is a
> *minimum* requirement, not an exact requirement or a maximal
> requirement.

Of course, stupid me... sorry.

But let's imagine that each feature has a minimum and possibly a maximum 
cmake version where it's supported. So, if we specify in the script 
which cmake version it is written to, in cmake code one could do

// This feature is valid from version 2.3.1 up to current version
// (2.6.0)
if(valid_versions("2.3.1",""))
{
	// implement feature1
}

// This other feature is valid from versions 2.3.4 to 2.4.3
if(valid_versions("2.3.4", "2.4.3")
{
	// implement feature2
}


So, if we specify that the script expects cmake to be version 2.3.2, 
only feature1 would be available. If the script is for version 2.4.0, 
both feature1 and feature2 would be available. Finally, if we expect 
cmake 2.5.4, feature1 would be in.

Now, say we're running an old cmake with a script written for a new 
cmake. Simply it wouldn't accept to parse the script because it uses new 
constructs. And finally the opposite, we have a new cmake parsing an old 
script... the if's in cmake code would cope with backward capabilities.

Suppose we don't want to support feature1 no more in cmake 2.7. Well, we 
just replace the first if condition to:

if(valid_versions("2.3.1","2.6.9")
{
	// implement feature1
}

And that'll be it, 2.6.9 would be the last version where feature1 is 
supported, but old scripts would run flawlessly.

I really think I've included every situation... but again, I might be 
completely wrong. If so, sorry for the noise :)

Regards,
rod



More information about the CMake mailing list