Add -write-options-for-conan configure argument
Passing this configure argument will generate a JSON file that contains information about configure options and features. This file is used by Qt's conan recipes. Fixes: QTBUG-92082 Change-Id: I2057ec8cbdb0a1ea198d7eeacb45f65bfa862d8a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
e5686b35f0
commit
3886db82c6
@ -28,10 +28,10 @@ endmacro()
|
|||||||
if("${MODULE_ROOT}" STREQUAL "")
|
if("${MODULE_ROOT}" STREQUAL "")
|
||||||
# If MODULE_ROOT is not set, assume that we want to build qtbase or top-level.
|
# If MODULE_ROOT is not set, assume that we want to build qtbase or top-level.
|
||||||
get_filename_component(MODULE_ROOT ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
get_filename_component(MODULE_ROOT ".." ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
set(auto_detect_generator TRUE)
|
set(qtbase_or_top_level_build TRUE)
|
||||||
else()
|
else()
|
||||||
file(TO_CMAKE_PATH "${MODULE_ROOT}" MODULE_ROOT)
|
file(TO_CMAKE_PATH "${MODULE_ROOT}" MODULE_ROOT)
|
||||||
set(auto_detect_generator FALSE)
|
set(qtbase_or_top_level_build FALSE)
|
||||||
endif()
|
endif()
|
||||||
set(configure_filename "configure.cmake")
|
set(configure_filename "configure.cmake")
|
||||||
set(commandline_filename "qt_cmdline.cmake")
|
set(commandline_filename "qt_cmdline.cmake")
|
||||||
@ -57,7 +57,9 @@ list(TRANSFORM configure_args STRIP)
|
|||||||
list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\")
|
list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\")
|
||||||
unset(generator)
|
unset(generator)
|
||||||
set(auto_detect_compiler TRUE)
|
set(auto_detect_compiler TRUE)
|
||||||
|
set(auto_detect_generator ${qtbase_or_top_level_build})
|
||||||
unset(device_options)
|
unset(device_options)
|
||||||
|
unset(options_json_file)
|
||||||
set_property(GLOBAL PROPERTY UNHANDLED_ARGS "")
|
set_property(GLOBAL PROPERTY UNHANDLED_ARGS "")
|
||||||
while(NOT "${configure_args}" STREQUAL "")
|
while(NOT "${configure_args}" STREQUAL "")
|
||||||
list(POP_FRONT configure_args arg)
|
list(POP_FRONT configure_args arg)
|
||||||
@ -69,6 +71,8 @@ while(NOT "${configure_args}" STREQUAL "")
|
|||||||
set(auto_detect_compiler FALSE)
|
set(auto_detect_compiler FALSE)
|
||||||
elseif(arg STREQUAL "-list-features")
|
elseif(arg STREQUAL "-list-features")
|
||||||
set(list_features TRUE)
|
set(list_features TRUE)
|
||||||
|
elseif(arg STREQUAL "-write-options-for-conan")
|
||||||
|
list(POP_FRONT configure_args options_json_file)
|
||||||
elseif(arg STREQUAL "-skip")
|
elseif(arg STREQUAL "-skip")
|
||||||
list(POP_FRONT configure_args qtrepo)
|
list(POP_FRONT configure_args qtrepo)
|
||||||
push("-DBUILD_${qtrepo}=OFF")
|
push("-DBUILD_${qtrepo}=OFF")
|
||||||
@ -151,6 +155,7 @@ defstub(qt_set01)
|
|||||||
# Define functions/macros that are called in qt_cmdline.cmake files
|
# Define functions/macros that are called in qt_cmdline.cmake files
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
|
unset(commandline_known_options)
|
||||||
unset(commandline_custom_handlers)
|
unset(commandline_custom_handlers)
|
||||||
set(commandline_nr_of_prefixes 0)
|
set(commandline_nr_of_prefixes 0)
|
||||||
set(commandline_nr_of_assignments 0)
|
set(commandline_nr_of_assignments 0)
|
||||||
@ -169,6 +174,7 @@ function(qt_commandline_option name)
|
|||||||
set(multiValueArgs VALUES MAPPING)
|
set(multiValueArgs VALUES MAPPING)
|
||||||
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
set(commandline_known_options "${commandline_known_options};${name}" PARENT_SCOPE)
|
||||||
set(commandline_option_${name} "${arg_TYPE}" PARENT_SCOPE)
|
set(commandline_option_${name} "${arg_TYPE}" PARENT_SCOPE)
|
||||||
if(NOT "${arg_NAME}" STREQUAL "")
|
if(NOT "${arg_NAME}" STREQUAL "")
|
||||||
set(commandline_option_${name}_variable "${arg_NAME}" PARENT_SCOPE)
|
set(commandline_option_${name}_variable "${arg_NAME}" PARENT_SCOPE)
|
||||||
@ -453,6 +459,76 @@ if(list_features)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
function(write_options_json_file)
|
||||||
|
if(qtbase_or_top_level_build)
|
||||||
|
# Add options that are handled directly by this script.
|
||||||
|
qt_commandline_option(qt-host-path TYPE string)
|
||||||
|
qt_commandline_option(no-guess-compiler TYPE void)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(indent " ")
|
||||||
|
set(content
|
||||||
|
"{"
|
||||||
|
"${indent}\"options\": {")
|
||||||
|
string(APPEND indent " ")
|
||||||
|
list(LENGTH commandline_known_options commandline_known_options_length)
|
||||||
|
set(i 1)
|
||||||
|
foreach(opt ${commandline_known_options})
|
||||||
|
list(APPEND content "${indent}\"${opt}\": {")
|
||||||
|
string(APPEND indent " ")
|
||||||
|
list(APPEND content "${indent}\"type\": \"${commandline_option_${opt}}\",")
|
||||||
|
if(NOT "${commandline_option_${opt}_values}" STREQUAL "")
|
||||||
|
set(values "${commandline_option_${opt}_values}")
|
||||||
|
list(TRANSFORM values PREPEND "\"")
|
||||||
|
list(TRANSFORM values APPEND "\"")
|
||||||
|
list(JOIN values ", " values)
|
||||||
|
list(APPEND content "${indent}\"values\": [${values}]")
|
||||||
|
elseif(NOT "${commandline_option_${opt}_mapping}" STREQUAL "")
|
||||||
|
list(LENGTH commandline_option_${opt}_mapping last)
|
||||||
|
math(EXPR last "${last} - 1")
|
||||||
|
set(values "")
|
||||||
|
list(APPEND content "${indent}\"values\": [")
|
||||||
|
foreach(k RANGE 0 "${last}" 2)
|
||||||
|
list(GET commandline_option_${opt}_mapping ${k} value)
|
||||||
|
list(APPEND values ${value})
|
||||||
|
endforeach()
|
||||||
|
list(TRANSFORM values PREPEND "\"")
|
||||||
|
list(TRANSFORM values APPEND "\"")
|
||||||
|
list(JOIN values ", " values)
|
||||||
|
list(APPEND content
|
||||||
|
"${indent} ${values}"
|
||||||
|
"${indent}]")
|
||||||
|
else()
|
||||||
|
list(APPEND content "${indent}\"values\": []")
|
||||||
|
endif()
|
||||||
|
string(SUBSTRING "${indent}" 4 -1 indent)
|
||||||
|
math(EXPR i "${i} + 1")
|
||||||
|
if(i LESS commandline_known_options_length)
|
||||||
|
list(APPEND content "${indent}},")
|
||||||
|
else()
|
||||||
|
list(APPEND content "${indent}}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
string(SUBSTRING "${indent}" 4 -1 indent)
|
||||||
|
|
||||||
|
set(features ${commandline_known_features})
|
||||||
|
list(TRANSFORM features PREPEND "\"")
|
||||||
|
list(TRANSFORM features APPEND "\"")
|
||||||
|
list(JOIN features ", " features)
|
||||||
|
|
||||||
|
list(APPEND content
|
||||||
|
"${indent}},"
|
||||||
|
"${indent}\"features\": [${features}]"
|
||||||
|
"}")
|
||||||
|
string(REPLACE ";" "\n" content "${content}")
|
||||||
|
file(WRITE "${options_json_file}" "${content}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(options_json_file)
|
||||||
|
write_options_json_file()
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
qtConfHasNextCommandlineArg(has_next)
|
qtConfHasNextCommandlineArg(has_next)
|
||||||
if(NOT has_next)
|
if(NOT has_next)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user