WindowsCopyFiles.cmake 1.1 KB

12345678910111213141516171819202122232425262728
  1. # Copyright 2016 Citra Emulator Project
  2. # Licensed under GPLv2 or any later version
  3. # Refer to the license.txt file included.
  4. # This file provides the function windows_copy_files.
  5. # This is only valid on Windows.
  6. # Include guard
  7. if(__windows_copy_files)
  8. return()
  9. endif()
  10. set(__windows_copy_files YES)
  11. # Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR.
  12. # This copying happens post-build.
  13. function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
  14. # windows commandline expects the / to be \ so switch them
  15. string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR})
  16. string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR})
  17. # /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output
  18. # cmake adds an extra check for command success which doesn't work too well with robocopy
  19. # so trick it into thinking the command was successful with the || cmd /c "exit /b 0"
  20. add_custom_command(TARGET ${TARGET} POST_BUILD
  21. COMMAND if not exist ${DEST_DIR} mkdir ${DEST_DIR} 2> nul
  22. COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0"
  23. )
  24. endfunction()