project() (Re: [karchive] /: Show how qmake integration can be done.)

Alexander Neundorf neundorf at kde.org
Mon Jan 6 21:33:53 UTC 2014


On Sunday 05 January 2014, you wrote:
> On Sunday 05 January 2014 20:39:37 Alexander Neundorf wrote:
> > how about extending the project( <name> [lang1 ... langN]) command ?
> > It already sets PROJECT_(SOURCE|BINARY)_DIR and
> > <name>_(SOURCE|BINARY)_DIR variables.
> > 
> > It could be
> > project(foo VERSION 1.2.3 C CXX)
> > and it could set the PROJECT_VERSION_... variables, and also
> > foo_VERSION_...  variables.
> 
> So this:
> 
> project(KArchive)
> set(KF5_VERSION "5.0.0")
> ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KARCHIVE
>                         VERSION_HEADER
> "${CMAKE_CURRENT_BINARY_DIR}/karchive_version.h" PACKAGE_VERSION_FILE
> "${CMAKE_CURRENT_BINARY_DIR}/KF5ArchiveConfigVersion.cmake")
> 
> would become this?
> 
> set(KF5_VERSION "5.0.0")
> project(KArchive $KF5_VERSION)
> ecm_setup_version(
>                         VERSION_HEADER
> "${CMAKE_CURRENT_BINARY_DIR}/karchive_version.h" PACKAGE_VERSION_FILE
> "${CMAKE_CURRENT_BINARY_DIR}/KF5ArchiveConfigVersion.cmake")
> 
> We still need ecm_setup_version, to generate these version files,
> but it could take the version from PROJECT_VERSION_*.
> This is SIC, but I understand that's not a problem yet.
> 
> (we could also keep the parsing of the first argument if set, for SC).
> 
> Works for me.
> But project() is not in ECM, it's in CMake, isn't it?

I pushed such an extension to project() to cmake stage, in the 
AddVersionToProjectCommand branch. This now also contains a modified 
write_basic_package_version_file() macro, which can now make use of that 
version.
I will see what cmake-devel thinks about it.

So you could do the following:

project(Foo VERSION 1.2.3)

...
write_basic_package_version_file(FooConfigVersion.cmake
                                 COMPATIBILITY AnyNewerVersion)

set_target_properties(.... VERSION ${PROJECT_VERSION}
                           SOVERSION ${PROJECT_VERSION_MAJOR} )




Without requiring this cmake version (3.0), probably the VERSION parameter 
could be optional for ecm_setup_version() and ecm_generate_pri_file() too, 
which could fall back to ${PROJECT_VERSION} in that case. If no VERSION 
argument has been used in ecm_generate_pri_file(), and no PROJECT_VERSION is 
set, it would error out.
Once cmake 3.0 is required, the VERSION argument to ecm_generate_pri_file() 
could then be removed.

Alex


More information about the Kde-buildsystem mailing list