PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/cmake/CMakeCopyIfDifferent.cmake

https://bitbucket.org/lindenlab/viewer-beta/
CMake | 41 lines | 24 code | 1 blank | 16 comment | 0 complexity | ac5ed037a63356ff0e24cb021a983799 MD5 | raw file
 1# -*- cmake -*-
 2# Taken from http://www.cmake.org/Wiki/CMakeCopyIfDifferent
 3# Generates a rule to copy each source file from source directory to destination directory.
 4#
 5# Typical use -
 6#
 7# SET(SRC_FILES head1.h head2.h head3.h)
 8# COPY_IF_DIFFERENT( /from_dir /to_dir IncludeTargets ${SRC_FILES})
 9# ADD_TARGET(CopyIncludes ALL DEPENDS ${IncludeTargets})
10
11MACRO(COPY_IF_DIFFERENT FROM_DIR TO_DIR TARGETS)
12# Macro to implement copy_if_different for a list of files
13# Arguments - 
14#   FROM_DIR - this is the source directory
15#   TO_DIR   - this is the destination directory
16#   TARGETS  - A variable to receive a list of targets
17#   FILES    - names of the files to copy 
18#              TODO: add globing. 
19SET(AddTargets "")
20FOREACH(SRC ${ARGN})
21    GET_FILENAME_COMPONENT(SRCFILE ${SRC} NAME) 
22    IF("${FROM_DIR}" STREQUAL "")
23        SET(FROM ${SRC})
24    ELSE("${FROM_DIR}" STREQUAL "")
25        SET(FROM ${FROM_DIR}/${SRC})
26    ENDIF("${FROM_DIR}" STREQUAL "")        
27    IF("${TO_DIR}" STREQUAL "")
28        SET(TO ${SRCFILE})
29    ELSE("${TO_DIR}" STREQUAL "")
30        SET(TO   ${TO_DIR}/${SRCFILE})
31    ENDIF("${TO_DIR}" STREQUAL "")
32    ADD_CUSTOM_COMMAND(
33        OUTPUT  "${TO}"
34        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FROM} ${TO}
35        DEPENDS ${FROM}
36        COMMENT "Copying ${SRCFILE} ${TO_DIR}"
37        )
38    SET(AddTargets ${AddTargets} ${TO})
39ENDFOREACH(SRC ${ARGN})
40SET(${TARGETS} ${AddTargets})
41ENDMACRO(COPY_IF_DIFFERENT FROM_DIR TO_DIR TARGETS)