CopyPattern.cmake 897 B

123456789101112131415161718192021222324252627
  1. # Filename: CopyPattern.cmake
  2. #
  3. # Description: This is a standalone version of CMake's file(COPY) command so we
  4. # can use all of its features during build-time instead of
  5. # config-time.
  6. #
  7. # Usage:
  8. # This script is invoked via add_custom_target, like this:
  9. # cmake -D SOURCE=[source directory]
  10. # -D DESTINATION=[destination directory]
  11. # -D FILES_MATCHING="[globbing patterns passed to file(COPY)]"
  12. # -P CopyPattern.cmake
  13. if(NOT DEFINED SOURCE OR NOT DEFINED DESTINATION)
  14. message(SEND_ERROR "CopyPattern.cmake requires SOURCE and DESTINATION to be
  15. defined.")
  16. endif()
  17. if(DEFINED FILES_MATCHING)
  18. separate_arguments(FILES_MATCHING UNIX_COMMAND ${FILES_MATCHING})
  19. file(COPY "${SOURCE}"
  20. DESTINATION "${DESTINATION}"
  21. FILES_MATCHING ${FILES_MATCHING})
  22. else()
  23. file(COPY "${SOURCE}"
  24. DESTINATION "${DESTINATION}")
  25. endif()