[cmake-developers] Adding MacroWriteBasicCMakeVersionFile.cmake file to cmake ?
Alexander Neundorf
neundorf at kde.org
Sun Jul 31 16:09:32 EDT 2011
On Sunday 31 July 2011, Brad King wrote:
> On 7/30/2011 3:33 AM, Rolf Eike Beer wrote:
> >> Another common scheme is to say that a version is compatible if the
> >> major version number matches and incompatible otherwise. I'm not
> >> saying we have to try to include every common scheme. I think just
> >> the basic one you proposed originally is sufficient. However, I'd
> >> like to come up with a name for it that will distinguish it from
> >> other schemes added in the future. Any ideas for a name?
> >
> > NewerVersionMatches and MajorVersionMatches?
>
> Those sound good, thanks!
Didn't know what the best way to do it would be, so there are now two branches
on stage, WriteConfigVersionFile and ConfigVersionFile_2Templates.
Both have the same purpose, but one provides a macro, which wraps the
configure_file() file call, and the other one provides two
ConfigVersion.cmake.in files, which the user can then use as input for
configure_file().
Usage with the macro is like this:
include(WriteBasicConfigVersionFile)
write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/XyzConfigVersion.cmake
VERSION 2.3.4 COMPATIBILITY SameMajorVersion )
Alternatively "AnyNewerVersion" can be used instead of "SameMajorVersion".
With the two input files usage is like this:
set(PROJECT_VERSION 1.2.3)
configure_file(
${CMAKE_ROOT}/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/XyzConfigVersion.cmake @ONLY )
Also here, alternatively BasicConfigVersion-AnyNewerVersion.cmake.in can be
used as input file.
And then in both cases:
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/XyzConfigVersion.cmake
${CMAKE_SOURCE_DIR}/XyzConfig.cmake
DESTINATION lib/cmake/xyz )
I'm not sure which syntax I like better. The one with the macro feels more
high-level, but maybe hides too much what is actually going on (which is not
much). The one where the user must use configure_file() directly feels more
low-level, but doesn't try to make a secret of what's going on, which may be
better to encourage users to write their own version files.
Which one would you prefer ?
I'll add tests for the one we decide to use.
Alex
More information about the cmake-developers
mailing list