Skip to content

Commit 1d4ec97

Browse files
author
Axel Heider
committed
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 <axel.heider@hensoldt.net>
1 parent 82db5f1 commit 1d4ec97

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

cmake-tool/helpers/cpio.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ function(MakeCPIO output_name input_files)
4444
set(archive_symbol ${MAKE_CPIO_CPIO_SYMBOL})
4545
endif()
4646

47+
get_filename_component(cpio_lib_name "${output_name}" NAME)
48+
get_filename_component(cpio_lib_dir "${output_name}" DIRECTORY)
49+
if(NOT cpio_lib_dir)
50+
set(cpio_lib_dir "${CMAKE_CURRENT_BINARY_DIR}")
51+
endif()
52+
4753
# intermediate files
48-
set(cpio_archive "archive.${output_name}.cpio")
49-
set(cpio_archive_s "${output_name}.S")
54+
set(cpio_archive "${cpio_lib_dir}/${cpio_lib_name}.cpio")
55+
set(cpio_archive_s "${cpio_lib_dir}/${cpio_lib_name}.S")
5056

5157
# Try to generate reproducible cpio archives using a command sequence that
5258
# 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)
5965
CheckCPIOArgument(cpio_reproducible_flag "--reproducible")
6066
set(
6167
cpio_cmd
62-
"cpio ${cpio_reproducible_flag} --quiet --create --format=newc --file=${CMAKE_CURRENT_BINARY_DIR}/${cpio_archive}"
68+
"cpio ${cpio_reproducible_flag} --quiet --create --format=newc --file=${cpio_archive}"
6369
)
64-
65-
set(tmp_dir "temp_${output_name}")
70+
set(tmp_dir "${cpio_lib_dir}/temp_${cpio_lib_name}")
6671
set(make_cpio "cd ${tmp_dir} && ${cpio_cmd}")
6772
foreach(file IN LISTS input_files)
6873
string(

0 commit comments

Comments
 (0)