From 798d367d54a6c6379ad355bd8345fa40e31e7fe9 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sat, 6 Sep 2008 18:24:57 -0500 Subject: Second Life viewer sources 1.21.0-RC --- linden/indra/cmake/CMakeCopyIfDifferent.cmake | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 linden/indra/cmake/CMakeCopyIfDifferent.cmake (limited to 'linden/indra/cmake/CMakeCopyIfDifferent.cmake') diff --git a/linden/indra/cmake/CMakeCopyIfDifferent.cmake b/linden/indra/cmake/CMakeCopyIfDifferent.cmake new file mode 100644 index 0000000..55e71ff --- /dev/null +++ b/linden/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} ${TO}) +ENDFOREACH(SRC ${ARGN}) +SET(${TARGETS} ${AddTargets}) +ENDMACRO(COPY_IF_DIFFERENT FROM_DIR TO_DIR TARGETS) -- cgit v1.1