CopyFilesGlob.cmake 518 B

123456789101112131415161718192021
  1. # Copy multiple files to destination, based on a glob expression
  2. # - FROM_GLOB
  3. # - TO
  4. if(NOT FROM_GLOB)
  5. message(FATAL_ERROR "FROM_GLOB must be set")
  6. endif()
  7. if(NOT TO)
  8. message(FATAL_ERROR "TO must be set")
  9. endif()
  10. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TO})
  11. file(GLOB files ${FROM_GLOB})
  12. foreach(file ${files})
  13. execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${file} ${TO} RESULT_VARIABLE rv)
  14. if(NOT rv EQUAL 0)
  15. message(FATAL_ERROR "Error copying ${file}")
  16. endif()
  17. endforeach()