From 1ca7dbfd5efebc3745be1c0bcb769f4e50576b0e Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.r.kempf@gmail.com>
Date: Wed, 28 Jan 2015 11:35:21 +0100
Subject: [PATCH] [CMake] add macro dune_symlink_to_source_files

add symlinks to the build tree, which point to files in the source tree.
Foreach file given in "files", a symlink of that name is created in the
corresponding build directory. Use for ini files, grid files etc. A warning
is issued on Windows systems.
---
 cmake/modules/DuneMacros.cmake | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake
index f6fc2b9f4..b3a9fbe68 100644
--- a/cmake/modules/DuneMacros.cmake
+++ b/cmake/modules/DuneMacros.cmake
@@ -1186,3 +1186,22 @@ macro(dune_symlink_to_source_tree)
     endforeach()
   endif()
 endmacro(dune_symlink_to_source_tree)
+
+# add symlinks to the build tree, which point to files in the source tree.
+# Foreach file given in "files", a symlink of that name is created in the
+# corresponding build directory. Use for ini files, grid files etc. A warning
+# is issued on Windows systems.
+macro(dune_symlink_to_source_files files)
+  # check for Windwos to issue a warning
+  if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+    if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING)
+      message(WARNING "Your module wanted to create symlinks, but you cannot do that on your platform.")
+      set(DUNE_WINDOWS_SYMLINK_WARNING)
+    endif()
+  else()
+    # create symlinks for all given files
+    foreach(f ${files})
+      execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}")
+    endforeach()
+  endif()
+endmacro(dune_symlink_to_source_files files)
-- 
GitLab