[cmake-developers] find_package module-only policy

Brad King brad.king at kitware.com
Mon Feb 20 17:43:47 EST 2012


On 2/20/2012 5:01 PM, Alexander Neundorf wrote:
> I don't have a strong opinion on this, but I'd prefer CONFIG_MODE over CONFIG
> for two reasons:
> * find_package_handle_standard_args() already knows the keyword CONFIG_MODE,
> so I wouldn't introduce a second similar but slightly different keyword to
> mean the same
> * CONFIG_MODE is more different from CONFIGS than CONFIG

FPHSA is an internal implementation detail for Find modules.  It is
not part of a major API.  I do have a strong opinion on this.  The new
find_package option will be called "CONFIG", please.

> There is now a branch FindPackage_ModeWarning on stage.
> It is branched away from the FindPackage_CONFIG_MODE_MODULE_MODE branch.
>
> - default mode is unchanged.
> - MODULE_MODE uses only the Find-modules
> - NO_MODULE == CONFIG_MODE uses only the config files.
> - warning messages are printed, but they are not finished, to say the least
>
> It warns if:
> * the required version is<  2.8.8, and MODULE_MODE or CONFIG_MODE has been
> used

Good, except for s/_MODE//.

> * the required version is<  2.8.8, CMAKE_FIND_PACKAGE_WARN_NO_MODULE is TRUE,
> no Find-module has been found and NO_MODULE has not been used

Good.

> * the required version is>= 2.8.8, no Find-module has been found, and no mode
> keyword has been used
>
> Is that what you meant ?

Yes, thanks.

 > And I still think the error message as it is (in the branch), is correct, it
 > doesn't *create* any ambiguity. All it does is, it explains the actual
 > situation to the user.
 > The problem that it is unclear to the user (and to cmake) what is needed, is
 > already there, because due to the automatic fallback it actually is unclear
 > what is needed.

IMO it is very clear to CMake what is needed.  The documented
equivalent to the new CONFIG mode keyword option has always been
to NOT provide a Find module in the CMAKE_MODULE_PATH.  It's
really not that hard to put a Find module in your source tree and
set CMAKE_MODULE_PATH to point at it.  By NOT doing that one tells
CMake to use Config mode.  IMO if developers do crazy tricks with
setting the CMAKE_MODULE_PATH to places outside their source tree
then they should be on their own.

I'm still not happy about warning without a CONFIG or NO_MODULE
keyword.  I think the message wording can be made good enough to
solve this problem, especially when the new CONFIG and MODULE
keywords can be used *optionally* to get even better messages.

> I think this doesn't change a lot compared to:
[snip]
> They both say the same, just the order is different.

The order is *everything*.  In the case that the project is written
correctly then your wording tells the user the *wrong* information
by focusing on the Find module first.  IMO that is one reason everyone
thinks that every project needs a Find module instead of a package
config file.  Even when they set up a Config file the error message
still asks for a Find module.

My wording makes it clear what the user needs to do when the project
is written correctly.  Then as a convenience it adds a note that
there might be a bug in the project.  Either way the proper course
of action is to look for the Config file.  If it is discovered that
the target package doesn't provide one then it is a bug in the
project trying to find it.

-Brad



More information about the cmake-developers mailing list