[cmake-developers] RFC: add version to project() call
brad.king at kitware.com
Wed Jan 29 09:58:44 EST 2014
On 1/28/2014 4:20 PM, Alexander Neundorf wrote:
>> (1) Design new behavior in a way that requires a change to the
>> project to activate.
> I think my current version fits (1).
Yes, I meant to add "like Alex's topic currently does".
> IMO this is not the place for a policy, since the behaviour of the existing,
> unchanged project did not change, it is still working as it did before.
...except for the case of set(PROJECT_VERSION) *before* a call to
project() without a VERSION. Currently your solution using
CMAKE_PROJECT_VERSION_SET_BY_PROJECT_COMMAND avoids needing the
policy. However, it is not a design that would have been
produced if we were starting from scratch. The purpose of a
policy is to allow us to switch to the clean design while
remaining compatible with existing code.
> Regarding (2): how should I detect whether PROJECT_VERSION has been set
> manually ?
Actually I realized we don't have to detect that. What matters
is that project() may clear the variable values when it did not
I reverted the 'AddVersionToProjectCommand' topic from 'next'
and replaced it with a 'project-version-variables' topic that
adds a policy:
Help: Format project command and variable documentation
project: Add optional LANGUAGES keyword
project: Manage VERSION variables
write_basic_package_version_file: use PROJECT_VERSION
The key is that project() only accepts VERSION when the
policy is set to NEW. After release this will be automatic
because one would need cmake_minimum_required() to specify a
high enough version to understand the new project() signature
and that would set the policy to NEW. Once the policy is
set to NEW then we can freely clear variables when project()
is not given a VERSION.
More information about the cmake-developers