[CMake] How to copy dependent files

David Cole david.cole at kitware.com
Tue Dec 16 09:51:21 EST 2008


${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}


On Sat, Dec 13, 2008 at 1:31 PM, Tron Thomas <tron.thomas at verizon.net>wrote:

> I have tried a different approach that has been more successful:
>
> add_custom_target(CopyXML ${CMAKE_COMMAND} -E copy_directory
>        ${CMAKE_CURRENT_SOURCE_DIR}/XML ${EXECUTABLE_OUTPUT_PATH}
>
> add_dependencies(UnitTest CopyXML)
>
> This will always copy the files whether they need to be updated or not,
> however I cannot think of anything else that will cause the file to get
> copied.
>
> Another problem is that when I build this target from an IDE like Apple's
> Xcode, the file are copied to ${EXECUTABLE_OUTPUT_PATH}, however the built
> executable is copied to ${EXECUTABLE_OUTPUT_PATH}/Debug when building the
> debug version the application.
>
> How can I get the copied files and built executable to appear in the same
> directory.
>
>
> On Dec 11, 2008, at 8:44 o'clock, Tron Thomas wrote:
>
>  I have a project configured with CMake that needs to have  set of XML
>> files copied to the directory where executables are built so that a unit
>> test that relies on these files can execute.
>>
>> I tried to create a custom command that should copy the files and tried to
>> set that command up as dependency of the unit test application.  However
>> when the application builds the files are not copied to the needed
>> directory.
>>
>> Here is the gist of how I tried to perform the copy:
>>
>> file(GLOB SourceXMLFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/XML
>> XML/*.xml)
>>
>> foreach(File ${SourceXMLFiles})
>>        set(XMLFiles "${XMLFiles} ${EXECUTABLE_OUTPUT_PATH}/${File}")
>> endforeach(File)
>>
>> add_custom_command(OUTPUT ${XMLFiles}
>>        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
>>                ${CMAKE_CURRENT_SOURCE_DIR}/XML ${EXECUTABLE_OUTPUT_PATH}
>>        DEPENDS ${SourceXMLFiles})
>>
>> add_dependencies(UnitTest ${XMLFiles})
>>
>> What can be done to copy the needed files to the unit test directory?
>>
>>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081216/f9fd9bf5/attachment.htm>


More information about the CMake mailing list