cmake: util: Add fmerge.cmake script
In order to merge multiple files into a single one, this convenience script is provided to be able to do so at build time in a manner compatible with all operating systems. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
parent
ff5452ef5c
commit
b8dd6ac741
1 changed files with 17 additions and 0 deletions
17
cmake/util/fmerge.cmake
Normal file
17
cmake/util/fmerge.cmake
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Merges a list of files into a destination file.
|
||||
# Usage: list of files as arguments, first argument is the destination file
|
||||
|
||||
MATH(EXPR ARGC "${CMAKE_ARGC}-1")
|
||||
# First 3 arguments are "cmake", "-P", and "process.cmake"
|
||||
if( ${CMAKE_ARGC} LESS 5)
|
||||
message(FATAL_ERROR "Not enough arguments")
|
||||
endif()
|
||||
|
||||
set(DEST_FILE ${CMAKE_ARGV3})
|
||||
# Empty the file
|
||||
file(REMOVE ${DEST_FILE})
|
||||
|
||||
foreach(i RANGE 4 ${ARGC})
|
||||
file(READ ${CMAKE_ARGV${i}} BUF)
|
||||
file(APPEND ${DEST_FILE} ${BUF})
|
||||
endforeach()
|
Loading…
Add table
Add a link
Reference in a new issue