MacroCopyFile.cmake 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. # - macro_copy_file(_src _dst)
  2. # Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
  3. #
  4. # Example:
  5. # macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/icon.png ${CMAKE_CURRENT_BINARY_DIR}/.)
  6. # Copies file icon.png to ${CMAKE_CURRENT_BINARY_DIR} directory
  7. #
  8. # Copyright (c) 2006-2007 Wengo
  9. # Copyright (c) 2006-2008 Andreas Schneider <asn@cryptomilk.org>
  10. #
  11. # Redistribution and use is allowed according to the terms of the BSD license.
  12. # For details see the accompanying COPYING file.
  13. macro (macro_copy_file _src _dst)
  14. # Removes all path containing .svn or CVS or CMakeLists.txt during the copy
  15. if (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
  16. if (CMAKE_VERBOSE_MAKEFILE)
  17. message(STATUS "Copy file from ${_src} to ${_dst}")
  18. endif (CMAKE_VERBOSE_MAKEFILE)
  19. # Creates directory if necessary
  20. get_filename_component(_path ${_dst} PATH)
  21. file(MAKE_DIRECTORY ${_path})
  22. execute_process(
  23. COMMAND
  24. ${CMAKE_COMMAND} -E copy_if_different ${_src} ${_dst}
  25. OUTPUT_QUIET
  26. )
  27. endif (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
  28. endmacro (macro_copy_file)