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

Marcus D. Hanwell marcus.hanwell at kitware.com
Thu Jun 9 10:50:54 EDT 2011


On Thu, Jun 9, 2011 at 9:19 AM, Brad King <brad.king at kitware.com> wrote:
> On 6/9/2011 8:50 AM, Alexander Neundorf wrote:
>>> What if the FindFoo.cmake script calls find_package(Bar) and does
>>> not require it but the project also does find_package(Bar) and does? I'm
>>> sure there are more cases I haven't listed here.
>>
>> I think this can be handled.
>> find_package() should error out in this case, because Bar was required but it
>> was disabled.
>> Maybe this option to disable a find_package() could even be provided for all
>> find_package() calls, and for each REQUIRED one it will cause an error. This
>> would create a bunch of unusable options, but would be very consistent ;-)
>
> Okay.  However, the option does not need to be "provided" as a
> gui-settable value for packagers to be able to disable things from build
> scripts.  The command could honor the value if it is present but not
> advertise it.

I think (as a former packager) that this would certainly go a long way
to addressing the issue for packages. If the packager passes in
--disable-find=Qt4 (or whatever command line syntax you use to expose)
then all calls to find_package(Qt4) fail, and you just made CMake
easier for packagers to use with little effort for developers in
changing their scripts.

Marcus



More information about the cmake-developers mailing list