From: Martin Quinson Date: Mon, 19 Jun 2017 21:20:52 +0000 (+0200) Subject: add a hardlinks target to ease working with out-of-tree builds X-Git-Tag: v3.16~30 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7f26b4f39dfece83faa378efd41f40f36a133446 add a hardlinks target to ease working with out-of-tree builds --- diff --git a/tools/cmake/Distrib.cmake b/tools/cmake/Distrib.cmake index 6a536775a3..da1a160519 100644 --- a/tools/cmake/Distrib.cmake +++ b/tools/cmake/Distrib.cmake @@ -223,6 +223,38 @@ add_custom_command( TARGET dist-dir COMMAND ${CMAKE_COMMAND} -E echo "${GIT_VERSION}" > ${PROJECT_NAME}-${release_version}/.gitversion) +########################################################## +### Link all sources to the bindir if srcdir != bindir ### +########################################################## +add_custom_target(hardlinks + COMMENT "Making the source files available from the bindir" +) +if (NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + foreach(file ${source_to_pack}) + #message(${file}) + # This damn prefix is still set somewhere (seems to be in subdirs) + string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}") + + # Create the directory on need + get_filename_component(file_location ${file} PATH) + string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_bindir}") + if(NOT OPERATION) + set(dirs_in_tarball "${dirs_in_bindir};${file_location};") + add_custom_command( + TARGET hardlinks + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${file_location}/) + endif() + + # Actually copy the file + add_custom_command( + TARGET hardlinks + COMMAND test -e ${CMAKE_BINARY_DIR}/${file} || echo "Hard link to ${CMAKE_HOME_DIRECTORY}/${file} ${CMAKE_BINARY_DIR}/${file}" + COMMAND test -e ${CMAKE_BINARY_DIR}/${file} || ln ${CMAKE_HOME_DIRECTORY}/${file} ${CMAKE_BINARY_DIR}/${file_location} + ) + endforeach(file ${source_to_pack}) +endif() + + ###################################### ### Fill in the "make dist" target ### ######################################