[cmake-developers] Adding argument "OPTIONAL" to find_package() and add_subdirectory

Nicolas Desprès nicolas.despres at gmail.com
Wed Jun 8 18:58:59 EDT 2011


On Wed, Jun 8, 2011 at 8:08 PM, Alexander Neundorf <neundorf at kde.org> wrote:
> On Tuesday, June 07, 2011 02:34:06 PM Eric Noulard wrote:
>> 2011/6/7 Alexander Neundorf <neundorf at kde.org>:
>> > On Monday, June 06, 2011 03:26:03 PM Brad King wrote:
>> >> On 06/04/2011 06:30 AM, Alexander Neundorf wrote:
>> [...]
>>
>> >> > What do you think about adding the keyword OPTIONAL to
>> >> > add_subdirectory ?
>> >> >
>> >> > Both have been proven useful, the one for find_package() especially
>> >> > for packagers.
>> >>
>> >> Ditto previous response.  These commands are primitives.  We should not
>> >> extend them with features unrelated to their basic purpose.
>> >
>> > While this is correct, it also keeps cmake a bit low-level.
>> > For this reason, we created such macros in KDE.
>> > Now our developers write stuff outside KDE, so either they can't use it,
>> > or they create copies of these files.
>> > This may be ok, but having 50 or 100 versions of these files and macros
>> > around in the net, some probably differing slightly, is also not a nice
>> > situation.
>>
>> Then it is possible to create a new CMake module,
>>
>> say
>>
>>  UseEnhancedConfigure.cmake
>>
>> which could be included in CMake as a contributed module maintained by KDE
>> dev. This new module would define something like:
>>
>> optional_find_package().
>> optional_add_subdirectory()
>>
>> this would make the feature available upstream, thus available outside KDE
>> and does not add extra feature to builtin configure.
>
> I can't think of any reason why somebody would want to use
> find_package(...without REQUIRED) instead of optional_find_package().
>
> Can somebody else see a reason ?
>

I have to confess that I never called find_package() without REQUIRED,
and I can't think about any use case right now.

-Nico



More information about the cmake-developers mailing list