Open halbux opened 3 years ago
I've found this so question that describes similar functionality. I'll try to implement it in a bit.
@halbux you may use this command for the mesh files:
function(custom_build_copy_file TARGET FROMDIRS TODIR GLOBS)
foreach(d IN LISTS FROMDIRS)
foreach(g IN LISTS GLOBS)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${d}/${g}" ${TODIR}/${DEST})
endforeach()
endforeach()
endfunction(custom_build_copy_file)
It has limitations though:
main.c
)Use it like other copy commands:
custom_build_copy_file(sparselizard ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} "*.msh")
Thanks a lot for that! Hm, I loved your symlink, sometimes meshes can be very large and you don't want to copy them. The touch however should be ok since we can assume the user changes the main.cpp when adding new mesh files. But symlink is definitely better so I'll leave it like it is.
function(custom_build_copy_file TARGET FROMDIRS TODIR GLOBS)
foreach(d IN LISTS FROMDIRS)
foreach(g IN LISTS GLOBS)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND find "${d}" -maxdepth 1 -iname '${g}' "|" xargs -I '{}' ln -fs '{}' ${TODIR} USES_TERMINAL)
endforeach()
endforeach()
endfunction(custom_build_copy_file)
This version creates symlinks but it uses shell commands, so it's not as portable.
Hi @matsievskiysv
I am absolutely enjoying using the cmake you provided for sparselizard, thanks again so much for that! :)
Everything is working perfectly with the symlink you created for the main.cpp and all other .msh files from sparselizard/simulation/default to build/simulation/default.
One minor issue however is that the symlink is done during the cmake config "cmake .." step... which means that if the user adds another .msh file to sparselizard/simulation/default then it is not made available in build/simulation/default by the cmake--build call . Is there a way to force cmake to do the symlink again at every build call also and not only at the initial cmake .. call?
Alex