[cmake-developers] CMakeFindDependencyMacro limitations

Stephen Kelly steveire at gmail.com
Mon Dec 21 10:07:46 EST 2015


Roger Leigh wrote:

> I've run into a few limitations in find_dependency.  I'm not sure if
> these are by design or could be fixed, so this is really a request for
> further explanation or design rationale.
> 
> The first issue is this:
> 
>    if (NOT ${dep}_FOUND)
> 
> This seems to be making the assumption that the found variable matches
> the dependency name, but the case used varies between modules and the
> name is case sensitive, from my reading of cmake-language.  Is this
> correct?

It is intentional, yes. See

 http://public.kitware.com/Bug/view.php?id=15412

The config-packages generated by cmake are canonical, so modules should set 
the ExactCase_FOUND to be a 'correct module'.

> Even if so, should this optimisation be put here rather than
> in find_package itself? 

I don't know the answer to this.

> If case sensitivity/naming is an issue, could
> the _FOUND variable be passed in as an argument, leaving the existing
> behaviour as the default if unspecified?

I don't think that's a good idea.

> The reason for stripping EXACT isn't clear.  If my package has a strict
> requirement on another package, whether the caller has an exact
> requirement for the version of my package has no bearing on the
> requirements I have for my dependencies as far as I understand.  What's
> the reason for the existing behaviour?

I don't know what you are referring to with 'stripping EXACT'. Perhaps you 
are looking at CMake < 3.0. See commit v3.0.0-rc2~10^2 (find_dependency: 
Don't propagate EXACT argument., 2014-03-06).

> Support for find_package arguments is limited to the dependency name and
> optionally the version.  

... and optionally EXACT.

> I can understand why REQUIRED and related
> arguments are omitted--that is why find_dependency exists--but I'd quite
> like to be able to specify COMPONENTS where needed e.g. with FindBoost,
> and this is not currently possible.

I don't remember whether this was discussed when designing find_dependency. 
Perhaps COMPONENTS could be added to the macro now.

> I was wondering if we could perhaps make find_dependency handle and pass
> through /all/ find_package arguments, minus REQUIRED/QUIET, so that
> find_dependency can expose the additional functionality offered by
> find_package.  Some may not be useful, in which case they could be
> omitted, but some like COMPONENTS may be required for the find_package
> call to be useful.

It might be possible, but might not be a good idea. What else do you want to 
pass in?

Thanks,

Steve.




More information about the cmake-developers mailing list