On 06/07/2011 10:28 AM, Alexander Neundorf wrote: > Hi, > > I slept over it, I think here's a better idea. > > For every find_package() which is not REQUIRED, some people or packagers may > want to explicitely disable each one of them. > > So how about this: > if there is no REQUIRED keyword in the find_package() call, there is always > an > option added which can be used to disable this find_package() call. > These options could be named DISABLE_PACKAGE_<PackageName>. > > This would > 1) make it possible to disable each of the optional dependencies explicitely > 2) these options will have the same standard name in all projects > 3) does not add additional arguments to the find_package() interface > > Options 1) and 2) are things regularly requested from developers used to > autotools. > > Alex
I would like to have such a feature. However, there is another use-case not covered by your proposal which is important for me. In my packages I include important dependencies and offer the user the choice to either 1. use the system-installed dependency if it is available 2. build the dependency from the code included in the package 3. if it is an optional dependency, don't use it at all I have some logic which goes along the following lines (for an optional dependency): option(DISABLE_PACKAGE_<PackageName> "Don't use <PackageName>" OFF) if(NOT DISABLE_PACKAGE_<PackageName>) find_package(<PackageName>) if(<PackageName>_FOUND) set(_DEFAULT_USE_SYSTEM_<PackageName> TRUE) else() set(_DEFAULT_USE_SYSTEM_<PackageName> FALSE) endif() option(USE_SYSTEM_<PackageName> "Use system-installed <PackageName>" ${_DEFAULT_USE_SYSTEM_<PackageName>}) if(USE_SYSTEM_<PackageName>) find_package(<PackageName> REQUIRED) else() add_subdirectory(externals/<PackageName>) endif() endif() If it is a hard dependency, just don't offer the DISABLE_PACKAGE_<PackageName> option, and always set it to OFF. I think your proposal and my above use-case should probably be best implemented in macros/functions and distributed either with CMake or some CMake modules library project. My 2c. Michael _______________________________________________ cmake-developers mailing list cmake-developers@cmake.org http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers