WindowsCopyFiles.cmake 1.1 KB

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