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

Alexander Neundorf neundorf at kde.org
Thu Jan 23 16:08:07 EST 2014


On Monday 06 January 2014, Alexander Neundorf wrote:
> Hi,
> 
> on cmake stage I have a simple branch AddVersionToProjectCommand.
> This extends the project command to also accept a version number:
> 
> project(Foo VERSION 1.2.3 CXX)
> 
> All that does is setting some more variables (beside PROJECT_NAME,
> PROJECT_SOURCE_DIR, PROJECT_BINARY_DIR and the <projectName>_...
> equivalents).
> 
> When setting a version, you also get PROJECT_VERSION and
> PROJECT_VERSION_(MAJOR|MINOR|PATCH|TWEAK) variables as well as the
> <projectName>_... equivalents.
> 
> These version variables can then be used in other commands/macros/functions
> which need a version.
> I modified write_basic_package_version_file() accordingly, so that you can
> now simply do
> 
> project(Foo VERSION 1.2.3)
> 
> ...
> 
> write_basic_package_version_file(FooConfigVersion.cmake
>                                  COMPATIBILITY AnyNewerVersion)
> 
> and this will use the version number from the project() call automatically
> (if no VERSION has been given explicitely).


Ok, I force-pushed my AddVersionToProjectCommand branch again.
Documentation is fixed, and after Steves comment not to overdo it with 
protecting the user from its own changes I removed the check for the actual 
value of PROJECT_VERSION again, since I think in case this breaks something, 
this will be very weird for the user.

I'd like to merge that into next soon.

Any more comments left ?

Alex



More information about the cmake-developers mailing list