Skip to content
Snippets Groups Projects
Commit ee8de2e9 authored by Dominic Kempf's avatar Dominic Kempf Committed by Carsten Gräser
Browse files

[bugfix][CMake][Release] Use named arguments in DuneSymlinkOrCopy


Passing multiple files to dune_symlink_to_source_files() was broken.
While at it, I switched the given macros to be functions and have
named arguments. Using positional arguments will result in a warning.

(cherry picked from commit 797fbfa1)
Signed-off-by: default avatarCarsten Gräser <graeser@dune-project.org>
parent f157ef8c
No related branches found
No related tags found
No related merge requests found
......@@ -27,16 +27,16 @@
# in the source tree. This file will be copied
# to the build tree.
#
# dune_symlink_to_source_tree()
# dune_symlink_to_source_tree([NAME name])
#
# add a symlink called src_dir to all directories in the build tree.
# add a symlink called NAME to all directories in the build tree (defaults to src_dir).
# That symlink points to the corresponding directory in the source tree.
# Call the macro from the toplevel CMakeLists.txt file of your project.
# You can also call it from some other directory, creating only symlinks
# in that directory and all directories below. A warning is issued on
# Windows systems.
#
# dune_symlink_to_source_files(files)
# dune_symlink_to_source_files(FILES 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
......@@ -63,7 +63,14 @@ macro(dune_add_copy_dependency target file_name)
add_dependencies(${target} "${target}_copy_${file_name}")
endmacro(dune_add_copy_dependency)
macro(dune_symlink_to_source_tree)
function(dune_symlink_to_source_tree)
# parse arguments
include(CMakeParseArguments)
cmake_parse_arguments(ARG "" "NAME" "" ${ARGN})
if(NOT ARG_NAME)
set(ARG_NAME "src_dir")
endif()
# check for Windows to issue a warning
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING)
......@@ -78,15 +85,22 @@ macro(dune_symlink_to_source_tree)
foreach(f ${files})
get_filename_component(dir ${f} DIRECTORY)
if(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/${dir}" "${CMAKE_BINARY_DIR}/${dir}/src_dir")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/${dir}" "${CMAKE_BINARY_DIR}/${dir}/${ARG_NAME}")
endif(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*")
endforeach()
endif()
endmacro(dune_symlink_to_source_tree)
endfunction(dune_symlink_to_source_tree)
function(dune_symlink_to_source_files)
# parse arguments
include(CMakeParseArguments)
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
if(ARG_UNPARSED_ARGUMENTS)
message(WARNING "You are using dune_symlink_to_source_files without named arguments (or have typos in your named arguments)!")
endif()
macro(dune_symlink_to_source_files files)
# create symlinks for all given files
foreach(f ${files})
foreach(f ${ARG_FILES})
# check for Windows to issue a warning
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING)
......@@ -99,4 +113,4 @@ macro(dune_symlink_to_source_files files)
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}")
endif()
endforeach()
endmacro(dune_symlink_to_source_files files)
endfunction(dune_symlink_to_source_files)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment