Skip to content

Commit

Permalink
cpio.cmake: allow passing a directory also
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Heider committed Mar 21, 2023
1 parent 82db5f1 commit 1d4ec97
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cmake-tool/helpers/cpio.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 1d4ec97

Please sign in to comment.