summaryrefslogtreecommitdiffstats
path: root/Modules/FeatureSummary.cmake
diff options
context:
space:
mode:
authorDaniele E. Domenichelli <ddomenichelli@drdanz.it>2017-02-03 14:32:34 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-06 19:44:23 (GMT)
commitf9bc8cfeeb956a5abbf293d8a26fb5b15aeec1d7 (patch)
tree596dbd4ad5906f0ab433e992fc315f64ba39b519 /Modules/FeatureSummary.cmake
parentfddc01bab3352d12c0eba1ff781b359a7dec529c (diff)
downloadCMake-f9bc8cfeeb956a5abbf293d8a26fb5b15aeec1d7.zip
CMake-f9bc8cfeeb956a5abbf293d8a26fb5b15aeec1d7.tar.gz
CMake-f9bc8cfeeb956a5abbf293d8a26fb5b15aeec1d7.tar.bz2
FeatureSummary: Add DEFAULT_DESCRIPTION option to feature_summary
If enabled and only one package type is selected, it will print the default title for the selected package type.
Diffstat (limited to 'Modules/FeatureSummary.cmake')
-rw-r--r--Modules/FeatureSummary.cmake46
1 files changed, 32 insertions, 14 deletions
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index f29a5f0..2913753 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -196,7 +196,7 @@ endfunction()
[VAR <variable_name>]
[INCLUDE_QUIET_PACKAGES]
[FATAL_ON_MISSING_REQUIRED_PACKAGES]
- [DESCRIPTION "<description>"]
+ [DESCRIPTION "<description>" | DEFAULT_DESCRIPTION]
[QUIET_ON_EMPTY]
WHAT (ALL
| PACKAGES_FOUND | PACKAGES_NOT_FOUND
@@ -247,7 +247,10 @@ endfunction()
information is "printed" into the specified variable. If ``FILENAME`` is
not used, the information is printed to the terminal. Using the
``DESCRIPTION`` option a description or headline can be set which will be
- printed above the actual content.
+ printed above the actual content. If only one type of
+ package was requested, no title is printed, unless it is explicitly set using
+ either ``DESCRIPTION`` to use a custom string, or ``DEFAULT_DESCRIPTION`` to
+ use a default title for the requested type.
If ``INCLUDE_QUIET_PACKAGES`` is given, packages which have been searched with
``find_package(... QUIET)`` will also be listed. By default they are skipped.
If ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` is given, CMake will abort if a
@@ -306,8 +309,14 @@ 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 QUIET_ON_EMPTY)
- set(oneValueArgs FILENAME VAR DESCRIPTION)
+ set(options APPEND
+ INCLUDE_QUIET_PACKAGES
+ FATAL_ON_MISSING_REQUIRED_PACKAGES
+ QUIET_ON_EMPTY
+ DEFAULT_DESCRIPTION)
+ set(oneValueArgs FILENAME
+ VAR
+ DESCRIPTION)
set(multiValueArgs WHAT)
CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
@@ -320,6 +329,11 @@ function(FEATURE_SUMMARY)
message(FATAL_ERROR "The call to FEATURE_SUMMARY() doesn't set the required WHAT argument.")
endif()
+ if(_FS_DEFAULT_DESCRIPTION AND DEFINED _FS_DESCRIPTION)
+ message(WARNING "DEFAULT_DESCRIPTION option discarded since DESCRIPTION is set.")
+ set(_FS_DEFAULT_DESCRIPTION 0)
+ endif()
+
set(validWhatParts "ENABLED_FEATURES"
"DISABLED_FEATURES"
"PACKAGES_FOUND"
@@ -332,11 +346,24 @@ function(FEATURE_SUMMARY)
"${_fsPkgType}_PACKAGES_NOT_FOUND")
endforeach()
+ set(title_ENABLED_FEATURES "The following features have been enabled:")
+ set(title_DISABLED_FEATURES "The following features have been disabled:")
+ set(title_PACKAGES_FOUND "The following packages have been found:")
+ set(title_PACKAGES_NOT_FOUND "The following packages have not been found:")
+ foreach(_fsPkgType ${_fsPkgTypes})
+ set(title_${_fsPkgType}_PACKAGES_FOUND "The following ${_fsPkgType} packages have been found:")
+ set(title_${_fsPkgType}_PACKAGES_NOT_FOUND "The following ${_fsPkgType} packages have not been found:")
+ endforeach()
+
list(FIND validWhatParts "${_FS_WHAT}" indexInList)
if(NOT "${indexInList}" STREQUAL "-1")
_FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary ${_FS_INCLUDE_QUIET_PACKAGES} )
if(_featureSummary OR NOT _FS_QUIET_ON_EMPTY)
- set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n")
+ if(_FS_DEFAULT_DESCRIPTION)
+ set(_fullText "${title_${_FS_WHAT}}\n${_featureSummary}\n")
+ else()
+ set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n")
+ endif()
endif()
if(_featureSummary)
@@ -375,15 +402,6 @@ function(FEATURE_SUMMARY)
endforeach()
endif()
- set(title_ENABLED_FEATURES "The following features have been enabled:")
- set(title_DISABLED_FEATURES "The following features have been disabled:")
- set(title_PACKAGES_FOUND "The following packages have been found:")
- set(title_PACKAGES_NOT_FOUND "The following packages have not been found:")
- foreach(_fsPkgType ${_fsPkgTypes})
- set(title_${_fsPkgType}_PACKAGES_FOUND "The following ${_fsPkgType} packages have been found:")
- set(title_${_fsPkgType}_PACKAGES_NOT_FOUND "The following ${_fsPkgType} packages have not been found:")
- endforeach()
-
set(_fullText "${_FS_DESCRIPTION}")
foreach(part ${allWhatParts})
set(_tmp)