DevHeads.net

RFC: replacing MacroLogFeature.cmake with FeatureSummary.cmake

Hi,

in KDE we have the file MacroLogFeature.cmake which we use to print a summary
of found/missing packages at the end of a cmake run.
I added similar functionality later on in 2007 to cmake in the form of
FeatureSummary.cmake:
<a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:FeatureSummary" title="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:FeatureSummary">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#module:FeatureSummary</a>

Among others due to source compatibility requirements we are still using
MacroLogFeature.cmake in KDE, but I'd like to get rid of this and instead use
FeatureSummary.cmake from the not yet existing cmake 2.8.6, which means we
have some time to improve it so it does what we need.
The plan is to get this into cmake 2.8.6, so once we have the binary break
(and minor source compat. break) with Qt5 and KDE frameworks, to make the
switch here too.

* the REQUIRED keyword, to make the cmake run error out at the end if one of
the packages marked with this keyword have not been found

* the ability to report "runtime" dependencies, i.e. packages which have been
checked for at build time, but which are actually not used at build time, but
only at runtime. So the build will be successful if they are missing, but the
result will not run properly

* the ability to set not only a description of a package, but also one or more
usages/purposes.

How I imagine this is the following, e.g. for FindLibXml2.cmake:

inside FindLibXml2.cmake:
find_path(...)
find_library(...)
...
set_package_info(LibXml2 "XML processing library." "http://xmlsoft.org/")

and then in a project using LibXml2, let's assume koffice:

find_package(LibXml2)

set_package_properties(LibXml2 PROPERTIES
PURPOSE "Required for exporting spreadsheets to odt format in kspread")

and in some other part of the project:
set_package_properties(LibXml2 PROPERTIES
PURPOSE "Required for importing html files in kword")

find_package(DBus)
set_package_properties(DBus PROPERTIES TYPE RUNTIME
PURPOSE "Required to disable the screensaver via kpresenter")

which should then produce something like:

-- Found packages:
LibXml2, XML processing library., <http://xmlsoft.org>
* Required for exporting spreadsheets to odt format in kspread
* Required for importing html files in kword
...
-- Missing RUNTIME packages:
DBus, A desktop IPC bus, <http://dbus.freedesktop.org>
* Required to disable the screensaver via kpresenter

What do you think of this ?
More wishes ?
Should it do it in a different way ?

Alex

Comments

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By David Jarvie at 07/17/2011 - 18:43

On Wednesday 13 July 2011 20:16:58 Alexander Neundorf wrote:
Something else which would be useful would be to output the actual file names (library files, header files etc.) which were checked for but not found when looking for the missing packages. Trying to determine which distro package to install to satisfy the dependency isn't always straightforward, since distro package names aren't always the same as the cmake package names. In these cases, I quite often have to find the cmake module used to locate the package, and then look through the cmake module to work out the files it's looking for, in order to then be able to do a package search for my distro to find which package to install.

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Alexander Neundorf at 07/18/2011 - 14:48

On Monday 18 July 2011, David Jarvie wrote:
I agree that this would be useful, but this is just too much to present in the
summary.
It would have to contain for which files it checked, and in which directories.
This is a lot.
This should be done in the success/failure message during the cmake run, not
in the summary at the end IMO.

Alex

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By David Jarvie at 07/19/2011 - 03:30

On Mon, July 18, 2011 8:48 pm, Alexander Neundorf wrote:
Yes, outputting it at the point it is found to be missing would be fine.
The main thing is to provide an alternative to trawling through the cmake
modules for the information.

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Alexander Neundorf at 07/17/2011 - 14:31

Ok, there is now a branch FeatureSummaryImprovements on the cmake stage:
<a href="http://cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/FeatureSummaryImprovements" title="http://cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/FeatureSummaryImprovements">http://cmake.org/gitweb?p=stage/cmake.git;a=shortlog;h=refs/heads/Featur...</a>

It should have everything discussed here:
* every package can have multiple PURPOSEs
* every package has a dependency TYPE: RUNTIME < OPTIONAL < RECOMMENDED <
REQUIRED

* optionally, feature_summary() can abort if a REQUIRED package has not been
found

Usage is like this:

find_package(LibXml2)
# the following one ideally directly inside LibXml2:
set_package_properties(LibXml2 PROPERTIES
DESCRIPTION "XML processing library."
URL "http://xmlsoft.org/")

# and in the using project
set_package_properties(LibXml2 PROPERTIES
PURPOSE "Required for exporting spreadsheets to odt format in kspread"
TYPE RECOMMENDED
)

# and in some other part of the project:
set_package_properties(LibXml2 PROPERTIES
PURPOSE "Required for importing html files in kword"
TYPE OPTIONAL )

# or all in one call:
find_package(DBus)
set_package_properties(DBus PROPERTIES
DESCRIPTION "A desktop IPC bus"
URL "http://dbus.freedesktop.org>"
TYPE RUNTIME
PURPOSE "Required to disable the screensaver via kpresenter")

The call to feature_summary() equivalent to what we have now is:
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

Please give it a try, let me know about issues you find or whether it's just
nice.
Also, I'm happy about patches which improve the documentation or the output
format (or anything else).

Alex

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Ian Wadham at 07/13/2011 - 19:49

On 14/07/2011, at 5:16 AM, Alexander Neundorf wrote:
Very nice. I especially like the PURPOSE concept.

As we discussed before, in connection with use of OpenAL sound
in some games, could it be possible to have grades of requirement
in between REQUIRED and OPTIONAL? They would not bomb out
the cmake run, but should issue some stronger message that the
requirement was not met than just saying it was "optional".

OTOH, after completion of moves to git, maybe "medium to strong"
requirements of individual apps can be made REQUIRED without
bombing out the cmake run of the "module" to which they belong.
I presume the Superbuild of a "module" can survive the failure of
one of its cmake runs (?).

Cheers, Ian W.

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Michael Jansen at 07/13/2011 - 20:42

On Thursday 14 July 2011 10:49:50 Ian Wadham wrote:
I would suggest RECOMMENDED. Like it works without but we think its really
less useful then.

OPTIONAL would be stuff then that enabled additional functionality that is not
really needed for all of us. like something that add iphone support. not
everyone has one.

Mike

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Sune Vuorela at 07/14/2011 - 05:20

On Thursday 14 July 2011 03:42:01 Michael Jansen wrote:
Several packaging systems has 3 levels of relations.
stuff that must be there.
RPM-language: Requires. Deb-language: Depends.

optional stuff that should be there by default on normal systems
RPM-language: Recommends. Deb-language: Recommends

Optional stuff that gives something extra
RPM-language: Suggests. Deb-language: Suggests.

Maybe we could be inspired by that?

Note that on debian systems, apt and aptitude installs Depends and Recommends
by default, and allows Recommends to be removed without removing other
package.
Yum don't know about Recommends nor Suggests and just installs Required
packages.

/Sune

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Alexander Neundorf at 07/14/2011 - 13:48

On Thursday 14 July 2011, Sune Vuorela wrote:
Thanks for the feedback :-)
So, levels would be:
* REQUIRED
* RECOMMENDED
* OPTIONAL

Should the output be

Missing REQUIRED packages:
* A
* B
* C

Missing RECOMMENDED packages:
* E
* F
* G

or would

Missing packages:
* A (REQUIRED)
* B (REQUIRED)
* C (REQUIRED)
* E (RECOMMENDED)
* F (RECOMMENDED)
* G (RECOMMENDED)

be also ok ?
I guess the first option is easier to read (for humans), while the second
would be easier to parse (for a program).

Now, anybody feels like giving this a shot ?
I'm maintaining that file currently in cmake, so I can simply commit/push it,
and I'd happily hand maintainership over :-)

Alex

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Alexander Neundorf at 08/04/2011 - 15:14

On Thursday 14 July 2011, Alexander Neundorf wrote:
Ok, this is now in cmake git master.
Please give it a try, so it will have everything we need in the next cmake
release (2.8.6).

Alex

Re: RFC: replacing MacroLogFeature.cmake with FeatureSummary.cma

By Johannes Sixt at 07/15/2011 - 01:38

Am 7/14/2011 20:48, schrieb Alexander Neundorf:
IMHO the output should be

Missing RECOMMENDED packages:
* E
* F
* G

Missing REQUIRED packages:
* A
* B
* C

so that the real errors and are immediately above the command prompt; if
you have a largish list of missing (recommended) packages, you would
otherwise have to scroll back to see the real errors.

-- Hannes