[cmake-developers] RFC: add version to project() call

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Jan 10 15:29:31 EST 2014


On 2014-01-10 15:15, Alexander Neundorf wrote:
> On Friday 10 January 2014, Matthew Woehlke wrote:
>> Related: Do these affect the version properties of libraries? (Because
>> OTOH if it does, I can imagine wanting to say VERSION once at the root
>> and have it inherit downwards unless overridden. Maybe though that's a
>> reason for it to not do so.)
>
> I thought about that too.
> Even without it, with the patch you now already have a standard form:
>
> set_target_properties(.... PROPERTIES VERSIOn ${PROJECT_VERSION} )
>
> Automatically doesn't really work, or at least it would have to be switched
> on:
> set(CMAKE_USE_PROJECT_VERSION_FOR_LIBRARIES TRUE)
> and then that property would automatically use ${PROJECT_VERSION}.

The problem with that is that it doesn't work if I use an unversioned 
project somewhere, when what I want is to use the version of the project 
from a parent directory. Unfortunately I can't think of a way to make 
that work properly that doesn't risk breaking things if Project A 
doesn't use it, but is built as a child of Project B which does (i.e. 
you don't want A to use B's version).

Hence my disinclination to try to address that just now :-).

(The "least evil" option I can come up with offhand is to accept 
'INHERIT' as the version and then always use the current-project version 
by default. At least that way, e.g. in the above example A would 
continue to get no version, so you haven't broken BC. You'd still have 
to explicitly set the project version on every project to use automatic 
versioning, even if it is 'INHERIT', hence why it's not a perfect solution.)

-- 
Matthew




More information about the cmake-developers mailing list