CMake: Clean up run_pzip

This should get rid of stray directories in the build
directory on Windows.
This commit is contained in:
Sam Edwards 2018-10-09 00:37:23 -06:00
parent 149303f04c
commit f696bfbfe2
1 changed files with 12 additions and 9 deletions

View File

@ -10,20 +10,23 @@ function(run_pzip target_name source destination glob)
file(GLOB_RECURSE files RELATIVE "${source}" "${source}/${glob}")
set(dstfiles "")
foreach(srcfile ${files})
file(RELATIVE_PATH srcfile_rel "${destination}" "${source}/${srcfile}")
file(RELATIVE_PATH dstfile_rel "${destination}" "${destination}/${srcfile}.pz")
foreach(filename ${files})
string(REGEX REPLACE "^/" "" filename "${filename}")
file(RELATIVE_PATH srcfile "${destination}" "${source}/${filename}")
list(APPEND dstfiles "${dstfile_rel}")
add_custom_command(OUTPUT "${dstfile_rel}"
COMMAND pzip -c > "${dstfile_rel}" < "${srcfile_rel}"
get_filename_component(dstdir "${destination}/${filename}" DIRECTORY)
file(MAKE_DIRECTORY "${dstdir}")
set(dstfile "${filename}.pz")
list(APPEND dstfiles "${destination}/${dstfile}")
add_custom_command(OUTPUT "${destination}/${dstfile}"
COMMAND pzip -c > "${dstfile}" < "${srcfile}"
WORKING_DIRECTORY "${destination}"
DEPENDS pzip
COMMENT "")
get_filename_component(dstdir "${destination}/${dstfile_rel}" DIRECTORY)
file(MAKE_DIRECTORY "${dstdir}")
endforeach(srcfile)
endforeach(filename)
add_custom_target(${target_name} ALL
DEPENDS ${dstfiles}