diff options
author | Bryan O'Sullivan <bos@lindenlab.com> | 2008-06-02 21:14:31 +0000 |
---|---|---|
committer | Bryan O'Sullivan <bos@lindenlab.com> | 2008-06-02 21:14:31 +0000 |
commit | 9db949eec327df4173fde3de934a87bedb0db13c (patch) | |
tree | aeffa0f0e68b1d2ceb74d460cbbd22652c9cd159 /indra/cmake/CMakeCopyIfDifferent.cmake | |
parent | 419e13d0acaabf5e1e02e9b64a07648bce822b2f (diff) |
svn merge -r88066:88786 svn+ssh://svn.lindenlab.com/svn/linden/branches/cmake-9-merge
dataserver-is-deprecated
for-fucks-sake-whats-with-these-commit-markers
Diffstat (limited to 'indra/cmake/CMakeCopyIfDifferent.cmake')
-rw-r--r-- | indra/cmake/CMakeCopyIfDifferent.cmake | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/indra/cmake/CMakeCopyIfDifferent.cmake b/indra/cmake/CMakeCopyIfDifferent.cmake new file mode 100644 index 0000000000..abbd1d0653 --- /dev/null +++ b/indra/cmake/CMakeCopyIfDifferent.cmake @@ -0,0 +1,41 @@ +# -*- cmake -*- +# Taken from http://www.cmake.org/Wiki/CMakeCopyIfDifferent +# Generates a rule to copy each source file from source directory to destination directory. +# +# Typical use - +# +# SET(SRC_FILES head1.h head2.h head3.h) +# COPY_IF_DIFFERENT( /from_dir /to_dir IncludeTargets ${SRC_FILES}) +# ADD_TARGET(CopyIncludes ALL DEPENDS ${IncludeTargets}) + +MACRO(COPY_IF_DIFFERENT FROM_DIR TO_DIR TARGETS) +# Macro to implement copy_if_different for a list of files +# Arguments - +# FROM_DIR - this is the source directory +# TO_DIR - this is the destination directory +# TARGETS - A variable to receive a list of targets +# FILES - names of the files to copy +# TODO: add globing. +SET(AddTargets "") +FOREACH(SRC ${ARGN}) + GET_FILENAME_COMPONENT(SRCFILE ${SRC} NAME) + IF("${FROM_DIR}" STREQUAL "") + SET(FROM ${SRC}) + ELSE("${FROM_DIR}" STREQUAL "") + SET(FROM ${FROM_DIR}/${SRC}) + ENDIF("${FROM_DIR}" STREQUAL "") + IF("${TO_DIR}" STREQUAL "") + SET(TO ${SRCFILE}) + ELSE("${TO_DIR}" STREQUAL "") + SET(TO ${TO_DIR}/${SRCFILE}) + ENDIF("${TO_DIR}" STREQUAL "") + ADD_CUSTOM_COMMAND( + OUTPUT "${TO}" + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FROM} ${TO} + DEPENDS ${FROM} + COMMENT "Copying ${SRCFILE} ${TO_DIR}" + ) + SET(AddTargets ${AddTargets} ${TARGET}) +ENDFOREACH(SRC ${ARGN}) +SET(${TARGETS} ${AddTargets}) +ENDMACRO(COPY_IF_DIFFERENT FROM_DIR TO_DIR TARGETS) |