Merge topic 'FeatureSummary_combine_WHAT_values'

8372b455 FeatureSummary: Add unit tests
d348cd1b FeatureSummary: Allow to combine and reorder values for the "WHAT" option
This commit is contained in:
Brad King 2014-03-05 11:07:55 -05:00 committed by CMake Topic Stage
commit f0dcbb1772
19 changed files with 140 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,20 +458,37 @@ 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"
"OPTIONAL_PACKAGES_FOUND"
"RECOMMENDED_PACKAGES_FOUND"
"REQUIRED_PACKAGES_FOUND"
set(allWhatParts "ENABLED_FEATURES"
"RUNTIME_PACKAGES_FOUND"
"OPTIONAL_PACKAGES_FOUND"
"RECOMMENDED_PACKAGES_FOUND"
"REQUIRED_PACKAGES_FOUND"
"DISABLED_FEATURES"
"RUNTIME_PACKAGES_NOT_FOUND"
"OPTIONAL_PACKAGES_NOT_FOUND"
"RECOMMENDED_PACKAGES_NOT_FOUND"
"REQUIRED_PACKAGES_NOT_FOUND"
)
"DISABLED_FEATURES"
"RUNTIME_PACKAGES_NOT_FOUND"
"OPTIONAL_PACKAGES_NOT_FOUND"
"RECOMMENDED_PACKAGES_NOT_FOUND"
"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:")
@ -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)

View File

@ -42,6 +42,7 @@ add_RunCMake_test(CompilerNotFound)
add_RunCMake_test(Configure)
add_RunCMake_test(DisallowedCommands)
add_RunCMake_test(ExternalData)
add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA)
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(GeneratorToolset)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.11)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,7 @@
-- The following features have been enabled:
\* Foo , Foo\.
-- The following features have been disabled:
\* Bar , Bar\.

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT ALL)

View File

@ -0,0 +1,7 @@
-- The following features have been disabled:
\* Bar , Bar\.
-- The following features have been enabled:
\* Foo , Foo\.

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT DISABLED_FEATURES ENABLED_FEATURES)

View File

@ -0,0 +1,6 @@
CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
The WHAT argument of FEATURE_SUMMARY\(\) contains ALL, which cannot be
combined with other values\.
Call Stack \(most recent call first\):
FeatureSummaryWhatListAll\.cmake:[0-9]+ \(feature_summary\)
CMakeLists.txt:[0-9]+ \(include\)

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT ENABLED_FEATURES ALL)

View File

@ -0,0 +1,6 @@
CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
value\.
Call Stack \(most recent call first\):
FeatureSummaryWhatListUnknown\.cmake:[0-9]+ \(feature_summary\)
CMakeLists.txt:[0-9]+ \(include\)

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT ENABLED_FEATURES FOO)

View File

@ -0,0 +1 @@
\* Foo , Foo\.

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT ENABLED_FEATURES)

View File

@ -0,0 +1,6 @@
CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
value\.
Call Stack \(most recent call first\):
FeatureSummaryWhatSingleUnknown\.cmake:[0-9]+ \(feature_summary\)
CMakeLists.txt:[0-9]+ \(include\)

View File

@ -0,0 +1,9 @@
include(FeatureSummary)
set(WITH_FOO 1)
set(WITH_BAR 0)
add_feature_info(Foo WITH_FOO "Foo.")
add_feature_info(Bar WITH_BAR "Bar.")
feature_summary(WHAT FOO)

View File

@ -0,0 +1,8 @@
include(RunCMake)
run_cmake(FeatureSummaryWhatAll)
run_cmake(FeatureSummaryWhatSingle)
run_cmake(FeatureSummaryWhatSingleUnknown)
run_cmake(FeatureSummaryWhatList)
run_cmake(FeatureSummaryWhatListUnknown)
run_cmake(FeatureSummaryWhatListAll)