1# SPDX-License-Identifier: Apache-2.0
2
3# Merges a list of files into a destination file.
4# Usage: list of files as arguments, first argument is the destination file
5
6MATH(EXPR ARGC "${CMAKE_ARGC}-1")
7# First 3 arguments are "cmake", "-P", and "process.cmake"
8if( ${CMAKE_ARGC} LESS 5)
9  message(FATAL_ERROR "Not enough arguments")
10endif()
11
12set(DEST_FILE ${CMAKE_ARGV3})
13# Empty the file
14file(REMOVE ${DEST_FILE})
15
16foreach(i RANGE 4 ${ARGC})
17  file(READ ${CMAKE_ARGV${i}} BUF)
18  file(APPEND ${DEST_FILE} ${BUF})
19endforeach()
20