From 7967e5ac64e6cb39672de5eb9cabd3827ebdbd54 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Thu, 7 Jul 2022 00:12:37 +0200 Subject: [PATCH] cpio.cmake: allow passing a directory also This allows creating the archive in a subfolder, so "pollution" of the root folder can be avoided. Signed-off-by: Axel Heider --- cmake-tool/helpers/cpio.cmake | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmake-tool/helpers/cpio.cmake b/cmake-tool/helpers/cpio.cmake index 913bb69d..f5f24ba2 100644 --- a/cmake-tool/helpers/cpio.cmake +++ b/cmake-tool/helpers/cpio.cmake @@ -44,9 +44,15 @@ function(MakeCPIO output_name input_files) set(archive_symbol ${MAKE_CPIO_CPIO_SYMBOL}) endif() + get_filename_component(cpio_lib_name "${output_name}" NAME) + get_filename_component(cpio_lib_dir "${output_name}" DIRECTORY) + if(NOT cpio_lib_dir) + set(cpio_lib_dir "${CMAKE_CURRENT_BINARY_DIR}") + endif() + # intermediate files - set(cpio_archive "archive.${output_name}.cpio") - set(cpio_archive_s "${output_name}.S") + set(cpio_archive "${cpio_lib_dir}/${cpio_lib_name}.cpio") + set(cpio_archive_s "${cpio_lib_dir}/${cpio_lib_name}.S") # Try to generate reproducible cpio archives using a command sequence that # runs in a separate shell in a temp folder. It creates an empty archive and @@ -59,10 +65,9 @@ function(MakeCPIO output_name input_files) CheckCPIOArgument(cpio_reproducible_flag "--reproducible") set( cpio_cmd - "cpio ${cpio_reproducible_flag} --quiet --create --format=newc --file=${CMAKE_CURRENT_BINARY_DIR}/${cpio_archive}" + "cpio ${cpio_reproducible_flag} --quiet --create --format=newc --file=${cpio_archive}" ) - - set(tmp_dir "temp_${output_name}") + set(tmp_dir "${cpio_lib_dir}/temp_${cpio_lib_name}") set(make_cpio "cd ${tmp_dir} && ${cpio_cmd}") foreach(file IN LISTS input_files) string(