RunPzip.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. function(run_pzip target_name source destination glob)
  2. file(GLOB_RECURSE files RELATIVE "${source}" "${source}/${glob}")
  3. set(dstfiles "")
  4. foreach(filename ${files})
  5. string(REGEX REPLACE "^/" "" filename "${filename}")
  6. get_filename_component(dstdir "${destination}/${filename}" DIRECTORY)
  7. if(TARGET host_pzip)
  8. set(dstfile "${filename}.pz")
  9. list(APPEND dstfiles "${destination}/${dstfile}")
  10. add_custom_command(OUTPUT "${destination}/${dstfile}"
  11. COMMAND ${CMAKE_COMMAND} -E make_directory "${dstdir}"
  12. COMMAND host_pzip -o "${destination}/${dstfile}" "${source}/${filename}"
  13. DEPENDS host_pzip
  14. COMMENT "")
  15. else()
  16. # If pzip isn't built, we just copy instead.
  17. list(APPEND dstfiles "${destination}/${filename}")
  18. add_custom_command(OUTPUT "${destination}/${filename}"
  19. COMMAND ${CMAKE_COMMAND} -E
  20. copy_if_different "${source}/${filename}" "${destination}/${filename}"
  21. COMMENT "")
  22. endif()
  23. endforeach(filename)
  24. add_custom_target(${target_name} ALL
  25. DEPENDS ${dstfiles}
  26. WORKING_DIRECTORY "${destination}")
  27. endfunction(run_pzip)