Skip to content

Commit b42a775

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 <[email protected]>
1 parent 514c5bf commit b42a775

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cmake-tool/helpers/cpio.cmake

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

47-
set(cpio_archive "${CMAKE_CURRENT_BINARY_DIR}/archive.${output_name}.cpio")
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+
else()
52+
set(cpio_lib_dir "${CMAKE_CURRENT_BINARY_DIR}/${cpio_lib_dir}")
53+
endif()
54+
55+
# intermediate files
56+
set(cpio_archive "${cpio_lib_dir}/${cpio_lib_name}.cpio")
4857

4958
# Create a script that prepares CPIO archive contents in a tmp folder and
5059
# then builds the archive. We have to pass the files to cpio in the same
@@ -56,7 +65,7 @@ function(MakeCPIO output_name input_files)
5665
# epoch (ie 0). The cpio parameter "--owner=+0:+0" sets user and group
5766
# values to 0:0.
5867
CheckCPIOArgument(cpio_reproducible_flag "--reproducible")
59-
set(cpio_archive_creator "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.sh")
68+
set(cpio_archive_creator "${cpio_lib_dir}/${cpio_lib_name}.sh")
6069
file(
6170
WRITE
6271
"${cpio_archive_creator}"
@@ -75,7 +84,7 @@ function(MakeCPIO output_name input_files)
7584

7685
# Create a "program" that makes the compiler generate and object file that
7786
# contains the cpio archive.
78-
set(cpio_archive_s "${CMAKE_CURRENT_BINARY_DIR}/${output_name}.S")
87+
set(cpio_archive_s "${cpio_lib_dir}/${cpio_lib_name}.S")
7988
file(
8089
WRITE
8190
"${cpio_archive_s}"

0 commit comments

Comments
 (0)