qt5base-lts/cmake/QtWriteArgsFile.cmake
Alexandru Croitor 0da123d67b CMake: Bump almost all cmake_minimum_required calls to 3.16
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Ieaf82c10987dd797d86a3fd4a986a67e72de486a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-09-22 19:36:49 +02:00

33 lines
1005 B
CMake

# This script writes its arguments to the file determined by OUT_FILE.
# Each argument appears on a separate line.
# This is used for writing the config.opt file.
#
# This script takes the following arguments:
# 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.16)
# 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)
foreach(i RANGE 1 ${SKIP_ARGS})
list(POP_FRONT args)
endforeach()
endif()
# Write config.opt
set(content "")
foreach(arg IN LISTS args)
if(NOT arg IN_LIST IGNORE_ARGS)
string(APPEND content "${arg}\n")
endif()
endforeach()
file(WRITE "${OUT_FILE}" "${content}")