FeatureSummary: Allow lists of dependencies in ADD_FEATURE_INFO

This commit is contained in:
Daniele E. Domenichelli 2017-01-20 19:02:29 +01:00
parent 9da7bf0825
commit f0165eb624
4 changed files with 35 additions and 2 deletions

View File

@ -477,7 +477,8 @@ endfunction()
add_feature_info(<name> <enabled> <description>)
Use this macro to add information about a feature with the given ``<name>``.
``<enabled>`` contains whether this feature is enabled or not.
``<enabled>`` contains whether this feature is enabled or not. It can be a
variable or a list of conditions.
``<description>`` is a text describing the feature. The information can
be displayed using ``feature_summary()`` for ``ENABLED_FEATURES`` and
``DISABLED_FEATURES`` respectively.
@ -489,7 +490,16 @@ endfunction()
option(WITH_FOO "Help for foo" ON)
add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
#]=======================================================================]
function(ADD_FEATURE_INFO _name _enabled _desc)
function(ADD_FEATURE_INFO _name _depends _desc)
set(_enabled 1)
foreach(_d ${_depends})
string(REGEX REPLACE " +" ";" _d "${_d}")
if(${_d})
else()
set(_enabled 0)
break()
endif()
endforeach()
if (${_enabled})
set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
else ()

View File

@ -0,0 +1,10 @@
-- The following features have been enabled:
\* Bar, Bar\.
\* Baz, Baz\.
\* Goo, Goo\.
-- The following features have been disabled:
\* Foo, Foo\.
\* Fez, Fez\.

View File

@ -0,0 +1,12 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo "WITH_FOO;WITH_BAR" "Foo.")
add_feature_info(Bar "WITH_FOO;NOT WITH_BAR" "Bar.")
add_feature_info(Baz "WITH_FOO AND NOT WITH_BAR" "Baz.")
add_feature_info(Goo "WITH_FOO OR WITH_BAR" "Goo.")
add_feature_info(Fez "NOT WITH_FOO OR WITH_BAR" "Fez.")
feature_summary(WHAT ALL)

View File

@ -13,3 +13,4 @@ run_cmake(FeatureSummaryTypes)
run_cmake(FeatureSummaryFatalOnMissingRequiredPackages)
run_cmake(FeatureSummaryIncludeQuietPackages)
run_cmake(FeatureSummaryQuietOnEmpty)
run_cmake(FeatureSummaryMultipleDepends)