FeatureSummary: Allow to combine and reorder values for the "WHAT" option

For example it is now possible to do:

  feature_summary(WHAT ENABLED_FEATURES
                       DISABLED_FEATURES)

That produces an output like:

  --
  -- The following features have been enabled:

   * Feature1
   * Feature2

  -- The following features have been disabled:
   * Feature2

Skipping the lists that are empty.

Without this patch this would require to do:

  message(STATUS "")
  feature_summary(WHAT ENABLED_FEATURES
      DESCRIPTION "The following features have been enabled:")
  feature_summary(WHAT DISABLED_FEATURES
      DESCRIPTION "The following features have been disabled:")

And empty lists would not be skipped.

The behaviour when WHAT has a single argument (ALL or any option) is
unchanged.
This commit is contained in:
Daniele E. Domenichelli 2014-02-28 17:36:38 +01:00
parent 8982a4b301
commit d348cd1bc5
1 changed files with 38 additions and 16 deletions

View File

@ -71,6 +71,13 @@
# RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME
# RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME
#
# With the exception of the ``ALL`` value, these values can be combined
# in order to customize the output. For example:
#
# ::
#
# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
#
#
#
# If a FILENAME is given, the information is printed into this file. If
@ -417,8 +424,8 @@ endfunction()
function(FEATURE_SUMMARY)
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(oneValueArgs FILENAME VAR DESCRIPTION WHAT)
set(multiValueArgs ) # none
set(oneValueArgs FILENAME VAR DESCRIPTION)
set(multiValueArgs WHAT)
CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
@ -451,7 +458,8 @@ function(FEATURE_SUMMARY)
set(requiredPackagesNotFound TRUE)
endif()
elseif("${_FS_WHAT}" STREQUAL "ALL")
else()
if("${_FS_WHAT}" STREQUAL "ALL")
set(allWhatParts "ENABLED_FEATURES"
"RUNTIME_PACKAGES_FOUND"
@ -466,6 +474,22 @@ function(FEATURE_SUMMARY)
"REQUIRED_PACKAGES_NOT_FOUND"
)
else()
set(allWhatParts)
foreach(part ${_FS_WHAT})
list(FIND validWhatParts "${part}" indexInList)
if(NOT "${indexInList}" STREQUAL "-1")
list(APPEND allWhatParts "${part}")
else()
if("${part}" STREQUAL "ALL")
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.")
else()
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.")
endif()
endif()
endforeach()
endif()
set(title_ENABLED_FEATURES "The following features have been enabled:")
set(title_DISABLED_FEATURES "The following features have been disabled:")
set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:")
@ -488,8 +512,6 @@ function(FEATURE_SUMMARY)
endif()
endif()
endforeach()
else()
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.")
endif()
if(_FS_FILENAME)