Commit f7498874 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[cmake] rename symlink function

parent fb57a0e8
# function to create a symbolic link between files in the source and build directories
function(frackit_symlink_or_copy)
function(frackit_link_from_build_dir)
# skip this if source and binary dir are the same
if( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
......@@ -11,29 +11,35 @@ function(frackit_symlink_or_copy)
include(CMakeParseArguments)
cmake_parse_arguments(ARG "" "DESTINATION" "FILES" ${ARGN})
if (ARG_UNPARSED_ARGUMENTS)
message(WARNING "There were issues parsing your arguments to frackit_symlink_or_copy_to_source)!")
message(WARNING "Unparsed arguments to frackit_link_from_build_dir)!")
endif ()
# handle all given files
# handle files
foreach (f ${ARG_FILES})
# check whether a speficic destination is desired
if (ARG_DESTINATION)
set(destination "${ARG_DESTINATION}/")
set(destination "${ARG_DESTINATION}")
else ()
set(destination "")
endif ()
# On windows, copy instead of linking
# On windows, make copy
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(NOT DEFINED FRACKIT_SYMLINK_WARNING)
message(WARNING "Symlinks are not supported on your platform! Doing copies instead.")
message(WARNING "Doing copy instead of symlink!")
set(FRACKIT_SYMLINK_WARNING)
endif()
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${destination}${f}")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "copy" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${destination}/${f}")
else ()
# create symlink
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${destination}${f}")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${destination}/${f}")
endif ()
endforeach ()
endfunction(frackit_link_from_build_dir)
function(frackit_symlink_or_copy)
if(NOT DEFINED FRACKIT_SYMLINK_DEPR_WARNING)
message(WARNING "This function is deprecated. Use frackit_link_from_build_dir instead!")
set(FRACKIT_SYMLINK_DEPR_WARNING)
endif()
frackit_link_from_build_dir(${ARGV})
endfunction(frackit_symlink_or_copy)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment