aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/dists/cmake/Modules/FileUtils.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/dists/cmake/Modules/FileUtils.cmake')
-rw-r--r--cmake/dists/cmake/Modules/FileUtils.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/dists/cmake/Modules/FileUtils.cmake b/cmake/dists/cmake/Modules/FileUtils.cmake
new file mode 100644
index 00000000..51707d5a
--- /dev/null
+++ b/cmake/dists/cmake/Modules/FileUtils.cmake
@@ -0,0 +1,29 @@
+# Copyright (c) 2009 Tobias Gunkel <tobigun@at@users.sourceforge.net>
+#
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved.
+
+function(FILE_SYMLINK old new)
+ if(NOT EXISTS ${old})
+ message(FATAL_ERROR "File \"${old}\" does not exist!")
+ endif(NOT EXISTS ${old})
+ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${old}" "${new}")
+ # ignore "link already exists" errors
+ if(NOT EXISTS ${new})
+ message(FATAL_ERROR "Symlink \"${old}\" to \"${new}\" failed!")
+ endif(NOT EXISTS ${new})
+endfunction(FILE_SYMLINK)
+
+function(FILE_COPY_DIR src dst)
+ if(NOT EXISTS ${src})
+ message(FATAL_ERROR "File \"${src}\" does not exist!")
+ endif(NOT EXISTS ${src})
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}"
+ RESULT_VARIABLE result
+ )
+ if(result)
+ message(FATAL_ERROR "Copy \"${src}\" to \"${dst}\" failed!")
+ endif(result)
+endfunction(FILE_COPY_DIR)