configure: Allow specifying arbitrary variable assignments
It's now possible to call configure with arbitrary variable assignments "FOO=BAR" that get passed as "-DFOO=BAR" to CMake. There is no error anymore for unknown variables. CMake already warns about those: "Manually-specified variables were not used by the project: FOO". [ChangeLog][configure] Users can directly assign CMake variables with configure, for example "configure CMAKE_CXX_COMPILE=clang++-11". Fixes: QTBUG-88210 Change-Id: Ib15e63a895df717919dd2b6623fa4d284209776f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
7451fb36fd
commit
c5409964b0
@ -543,6 +543,8 @@ if(options_json_file)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(cmake_var_assignments)
|
||||
|
||||
while(1)
|
||||
qtConfHasNextCommandlineArg(has_next)
|
||||
if(NOT has_next)
|
||||
@ -561,6 +563,12 @@ while(1)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Handle variable assignments
|
||||
if(arg MATCHES "^([a-zA-Z0-9_-]+)=(.*)")
|
||||
list(APPEND cmake_var_assignments "${arg}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# parse out opt and val
|
||||
set(nextok FALSE)
|
||||
if(arg MATCHES "^--?enable-(.*)")
|
||||
@ -903,6 +911,11 @@ if(generator)
|
||||
push(-G "${generator}")
|
||||
endif()
|
||||
|
||||
# Add CMake variable assignments near the end to allow users to overwrite what configure sets.
|
||||
foreach(arg IN LISTS cmake_var_assignments)
|
||||
push("-D${arg}")
|
||||
endforeach()
|
||||
|
||||
push("${MODULE_ROOT}")
|
||||
|
||||
# Restore the escaped semicolons in arguments that are lists
|
||||
|
Loading…
x
Reference in New Issue
Block a user