[CMake] Add_custom_target copying files

Michael Jackson mike.jackson at bluequartz.net
Sun Feb 15 10:40:21 EST 2009


Here is a code snippet from a project that I use that copies some  
files to the build directory.

#-- Copy all the HDF5 files from the test directory into the build  
directory
SET (HDF5_REFERENCE_TEST_FILES
   tnullspace.h5
   family_v1.7_00003.h5
   family_v1.7_00001.h5
   mergemsg.h5
   tbogus.h5
   tbad_msg_count.h5
   group_new.h5
   deflate.h5
   noencoder.h5
   family_v1.7_00000.h5
   le_extlink1.h5
   tmtimeo.h5
   tmtimen.h5
   fill_old.h5
   tlayouto.h5
   family_v1.7_00002.h5
   th5s.h5
   tarrold.h5
)

FOREACH ( h5_file ${HDF5_REFERENCE_TEST_FILES} )
    SET (dest "${PROJECT_BINARY_DIR}/${h5_file}")
    MESSAGE(STATUS " Copying ${dest}")
    ADD_CUSTOM_COMMAND (
      TARGET     ${HDF5_TEST_LIB_NAME}
      POST_BUILD
      COMMAND    ${CMAKE_COMMAND}
      ARGS       -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/$ 
{h5_file} ${dest}
      )

ENDFOREACH ( h5_file ${HDF5_REFERENCE_TEST_FILES} )

_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Feb 15, 2009, at 9:28 AM, Leopold Palomo Avellaneda wrote:

> Hi,
>
> I would like to create a custom target that copy "several" files  
> (one, two or
> n files, but at least one) to a directory. I know how to do it with  
> one file:
>
> add_custom_target(my_copy_target
> ${CMAKE_COMMAND} -E copy ${_inputfile} ${dirOUT}/)
>
> but, I really don't know how to do it with a list of files.
>
> Someone could help me?
>
> Regards,
>
> Leo
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list