[CMake] Apply FIND_PACKAGE_HANDLE_STANDARD_ARGS() on COMPONENTS

S Roderick kiwi.net at mac.com
Wed Apr 21 15:29:46 EDT 2010


On Apr 21, 2010, at 15:13 , Alexander Neundorf wrote:

> On Tuesday 20 April 2010, Michael Hertling wrote:
>> Dear CMake community, dear CMake developers,
>> 
> ...
>> There's another aspect related to this I'd like to comment on: During
>> the abovementioned considerations on the bug tracker and the mailing
>> list, the question has arisen if it's reasonable to set XXX_FOUND to
>> FALSE if any of the requested components aren't found. As for myself,
>> I'd say: No, it isn't. Let's have a look at the following scenario:
>> 
>> Package XXX normally provides components YY1 and YY2, but for some
>> reason, only YY1 is installed. Moreover, XXX provides a config file
>> XXXConfig.cmake. Now, a project's CMake script requests both YY1/2 by
>> FIND_PACKAGE(XXX COMPONENTS YY1 YY2). As Brad King has pointed out in
>> <http://www.mail-archive.com/cmake@cmake.org/msg15952.html>, finding a
>> config file results in XXX_FOUND to be set to TRUE automatically. Thus,
>> the absence of YY2 does not mean the absence of XXX as a whole in any
>> case, and, notwithstanding, the requesting CMake script should have a
>> chance to proceed even if YY2 isn't available, i.e. the following seems
>> reasonable: XXX_YY1_FOUND=TRUE, XXX_YY2_FOUND=FALSE *but* XXX_FOUND=TRUE.
> 
> I think I don't agree here.
> If I say
> find_package(XXX COMPONENTS YY1 YY2 REQUIRED)
> I think it makes a lot of sense to interpret this as "search package XXX, and 
> I need YY1 and YY2 from it".
> What other reason would I have to give YY1 and YY2 there otherwise ?
> If it still succeeds if they are not found, why should I list them then ?


+1

find_package(XXX COMPONENTS YY1 YY2 REQUIRED)

means to me, I _require_ both YY1 and YY2 from XXX. Any other YYx I don't care about.

The first version above translates to me to be

find_package(XXX COMPONENTS YY1 REQUIRED)

I only _require_ YY1.
Stephen


More information about the CMake mailing list