diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtWriteArgsFile.cmake | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/cmake/QtWriteArgsFile.cmake b/cmake/QtWriteArgsFile.cmake index ddb390a146..d21d050ed4 100644 --- a/cmake/QtWriteArgsFile.cmake +++ b/cmake/QtWriteArgsFile.cmake @@ -3,35 +3,30 @@ # This is used for writing the config.opt file. # # This script takes the following arguments: -# OUT_FILE: The output file. +# IN_FILE: The input file. The whole command line as one string. +# OUT_FILE: The output file. One argument per line. # SKIP_ARGS: Number of arguments to skip from the front of the arguments list. # IGNORE_ARGS: List of arguments to be ignored, i.e. that are not written. cmake_minimum_required(VERSION 3.3) -# Look for the -P argument to determine the start of the actual script arguments -math(EXPR stop "${CMAKE_ARGC} - 1") -set(start 0) -foreach(i RANGE 1 ${stop}) - if(CMAKE_ARGV${i} STREQUAL "-P") - math(EXPR start "${i} + 2") - break() - endif() -endforeach() +# Read arguments from IN_FILE and separate them. +file(READ "${IN_FILE}" raw_args) +separate_arguments(args NATIVE_COMMAND "${raw_args}") # Skip arguments if requested if(DEFINED SKIP_ARGS) - math(EXPR start "${start} + ${SKIP_ARGS}") + foreach(i RANGE 1 ${SKIP_ARGS}) + list(POP_FRONT args) + endforeach() endif() # Write config.opt set(content "") -if(start LESS_EQUAL stop) - foreach(i RANGE ${start} ${stop}) - set(arg ${CMAKE_ARGV${i}}) - if(NOT arg IN_LIST IGNORE_ARGS) - string(APPEND content "${arg}\n") - endif() - endforeach() -endif() +foreach(arg IN LISTS args) + if(NOT arg IN_LIST IGNORE_ARGS) + string(APPEND content "${arg}\n") + endif() +endforeach() + file(WRITE "${OUT_FILE}" "${content}") |