[CMake] providing library information, what's the cmake way
Eric Noulard
eric.noulard at gmail.com
Thu Nov 25 08:19:08 EST 2010
2010/11/25 Marcel Loose <loose at astron.nl>:
>>
>> Everyone looks into his local CMake documentation and uses what he
> finds
>> in there. And then it breaks on older versions. You currently have
> no
>> chance to know what works but to install all older versions and do a
>> binary search in the documentation. That simply does not scale.
>>
>> Eike
>
> That's what CMAKE_MINIMUM_REQUIRED() is for. If you're developing with
> CMake 2.8.2, and you want to make sure that you don't use any features
> that are not supported by CMake prior to version 2.8.2, you should put
> this at the top of your CMakeLists.txt file:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2)
Unless I'm wrong this is NOT ensuring what you said.
This statement will make CMake shout at you if you try
to use CMake version less than the specified version:
"If the current version of CMake is lower than that required it will
stop processing the project and report an error. When a version
higher than 2.4 is specified the command implicitly invokes
cmake_policy(VERSION major[.minor[.patch]])
which sets the cmake policy version level to the version specified.
When version 2.4 or lower is given the command implicitly invokes"
so the "minimum" required version is checked and the corrresponding
policy is enforced.
BUT... this does NOT ensure that while requiring minimum 2.8.2 and
you are currently using 2.8.3 (or any later version) your 2.8.3 will behave
as if it was 2.8.2.
If a new CMake command and/or option for an existing command has been
added between 2.8.2 and 2.8.3 but is not subject to some policy then
if you use it you won't get a warning.
but you'll break your user using CMake 2.8.2.
I think that's why Dave said:
"If you want to support CMake 2.6.4 (or whatever previous version you
require, for whatever reason), then you should be using *that* version
for your local development, and have that be the
cmake_minimum_required version. And use that version to look up
documentation..."
> But you do have a point. It would really help people developing CMake
> files to know whether they can use a given command or not if they want
> to support, say, CMake 2.6.0.
Thus my proposal based on Tyler idea to attach a list of version
to each CMake command/variables/properties which contains
the first CMake version which included the feature
followed by the list of CMake version which modified the behavior/feature.
> To be honest, the people at Kitware don't
> make that an easy job, because almost every patch-release contains new
> features :-(
May be they are too-responsive to user request :-]
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list