diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-11-01 12:30:30 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-02-15 15:47:29 +0100 |
commit | 360f181857778a46e1b4bc48bc5176337f92c059 (patch) | |
tree | f6fcf379150a27948835a711e2d3d07bcc879251 /cmake | |
parent | 0e1f290cadb0a99ad0791d3f26a07f66fd7b89ef (diff) |
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>
(cherry picked from commit c5409964b0c627b25131c73f95794314feb51b5d)
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 45cfdd3961..d7df9e142f 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -569,6 +569,8 @@ if(options_json_file) return() endif() +set(cmake_var_assignments) + while(1) qtConfHasNextCommandlineArg(has_next) if(NOT has_next) @@ -587,6 +589,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-(.*)") @@ -932,6 +940,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 |