[cmake-developers] CMakeFindDependencyMacro limitations

Roger Leigh rleigh at codelibre.net
Tue Dec 22 15:24:58 EST 2015


On 21/12/2015 15:07, Stephen Kelly wrote:
> 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'.

OK.

>> 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).

This one was me misreading the find_dependency macro--it's setting 
cmake_fd_exact_arg, so it is being passed.  My mistake.

>> 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?

Currently, for my own needs, COMPONENTS is the single missing piece.  If 
it would be possible to add this, it would certainly be very useful.

The other arguments might be potentially useful, that was more of a 
general question of which other bits might have general utility in the 
context of calling find_dependency from a config script.

I'd be happy to provide a patch for COMPONENTS if you like.


Kind regards,
Roger



More information about the cmake-developers mailing list