[cmake-developers] Adding argument "OPTIONAL" to find_package() and add_subdirectory
Alexander Neundorf
neundorf at kde.org
Sat Jun 4 06:30:28 EDT 2011
Hi,
again from the KDE sprint...
1) We have a macro
macro_optional_find_package().
The purpose is to be able to build without a specific package even if that
package is installed and would actually be found by the find_package() call.
Basically this is a wrapper around find_package(), but additionally it adds an
option WITH_Foo, which is enabled by default.
If disabled, the actual find_package() is not executed, and the variables
FOO_FOUND/INCLUDES/LIBRARIES are reset to empty, so that even if the package
hasn't been searched this time, results from previous runs are discarded.
What do you think about adding this as a built-in feature to find_package(),
i.e. add a argument OPTIONAL to find_package(), then probably also a
"COMMENT".
2) we have something similar for add_subdirectory(),
macro_optional_add_subdirectory().
The purpose is to disable parts of a big project by skipping the
add_subdirectory.
This is a wrapper around add_subdirectory(), but adds an option BUILD_FOO,
which is enabled by default.
If disabled, the actual add_subdirectory() is not executed.
Additionally there is an additional global option
DISABLE_ALL_OPTIONAL_SUBDIRECTORIES, which is disabled by default.
If enabled, all these optional subdirectories are disabled (but can be enabled
again one by one).
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.
Alex
More information about the cmake-developers
mailing list