diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-05 15:50:57 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-10 16:53:31 +0100 |
commit | 30a9b045cc6421b19898b070ed2cebaf734df174 (patch) | |
tree | 9afe236152d680d83450b6e3ee7b7be92d3ba0ff | |
parent | a3b9e3459f02d23c66b2a7fa5e2ea6fac03bbe82 (diff) |
CMake: Implement configure -list-features
Extend qt_configure_get_padded_string to make the feature list look like
qmake's.
Fixes: QTBUG-88144
Change-Id: I714f2b2f3537b506365a03b5b6bc3413e9cab167
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/QtBuildInformation.cmake | 23 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 26 | ||||
-rw-r--r-- | config_help.txt | 2 |
3 files changed, 49 insertions, 2 deletions
diff --git a/cmake/QtBuildInformation.cmake b/cmake/QtBuildInformation.cmake index 5a76b2070c..50ace2ea5d 100644 --- a/cmake/QtBuildInformation.cmake +++ b/cmake/QtBuildInformation.cmake @@ -140,13 +140,32 @@ macro(qt_configure_add_report_padded label message) set(__qt_configure_reports "${__qt_configure_reports}" PARENT_SCOPE) endmacro() +# Pad 'label' and 'value' with dots like this: +# "label ............... value" +# +# PADDING_LENGTH specifies the number of characters from the start to the last dot. +# Default is 30. +# MIN_PADDING specifies the minimum number of dots that are used for the padding. +# Default is 0. function(qt_configure_get_padded_string label value out_var) - set(pad_string ".........................................") + cmake_parse_arguments(arg "" "PADDING_LENGTH;MIN_PADDING" "" ${ARGN}) + if("${arg_MIN_PADDING}" STREQUAL "") + set(arg_MIN_PADDING 0) + endif() + if(arg_PADDING_LENGTH) + set(pad_string "") + math(EXPR n "${arg_PADDING_LENGTH} - 1") + foreach(i RANGE ${n}) + string(APPEND pad_string ".") + endforeach() + else() + set(pad_string ".........................................") + endif() string(LENGTH "${label}" label_len) string(LENGTH "${pad_string}" pad_len) math(EXPR pad_len "${pad_len}-${label_len}") if(pad_len LESS "0") - set(pad_len "0") + set(pad_len ${arg_MIN_PADDING}) endif() string(SUBSTRING "${pad_string}" 0 "${pad_len}" pad_string) set(output "${label} ${pad_string} ${value}") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index ea3fa1281a..cb92c0fbca 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -9,6 +9,7 @@ # TOP_LEVEL: TRUE, if this is a top-level build. include(${CMAKE_CURRENT_LIST_DIR}/QtFeatureCommon.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInformation.cmake) cmake_policy(SET CMP0007 NEW) cmake_policy(SET CMP0057 NEW) @@ -60,6 +61,8 @@ while(configure_args) set(auto_detect_generator FALSE) elseif(arg STREQUAL "-no-guess-compiler") set(auto_detect_compiler FALSE) + elseif(arg STREQUAL "-list-features") + set(list_features TRUE) elseif(arg STREQUAL "-skip") list(POP_FRONT configure_args qtrepo) push("-DBUILD_${qtrepo}=OFF") @@ -94,7 +97,10 @@ endwhile() set_property(GLOBAL PROPERTY COMMANDLINE_KNOWN_FEATURES "") function(qt_feature feature) + cmake_parse_arguments(arg "" "PURPOSE;SECTION;" "" ${ARGN}) set_property(GLOBAL APPEND PROPERTY COMMANDLINE_KNOWN_FEATURES "${feature}") + set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_PURPOSE_${feature} "${arg_PURPOSE}") + set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_SECTION_${feature} "${arg_SECTION}") endfunction() macro(defstub name) @@ -405,6 +411,26 @@ function(qt_call_function func) endif() endfunction() +if(list_features) + unset(lines) + foreach(feature ${commandline_known_features}) + get_property(section GLOBAL PROPERTY COMMANDLINE_FEATURE_SECTION_${feature}) + get_property(purpose GLOBAL PROPERTY COMMANDLINE_FEATURE_PURPOSE_${feature}) + if(purpose) + if(NOT "${section}" STREQUAL "") + string(APPEND section ": ") + endif() + qt_configure_get_padded_string("${feature}" "${section}${purpose}" line + PADDING_LENGTH 25 MIN_PADDING 1) + list(APPEND lines "${line}") + endif() + endforeach() + list(SORT lines) + list(JOIN lines "\n" lines) + message("${lines}") + return() +endif() + while(1) qtConfHasNextCommandlineArg(has_next) if(NOT has_next) diff --git a/config_help.txt b/config_help.txt index 4ae7028506..4c0c32b7c6 100644 --- a/config_help.txt +++ b/config_help.txt @@ -48,6 +48,8 @@ Configure meta: -feature-<feature> ... Enable <feature> -no-feature-<feature> Disable <feature> [none] + -list-features ....... List available features. Note that some features + have dedicated command line options as well. Build options: |