On 05/13/2010 05:58 AM, Clinton Stimpson wrote:
>>
>> Essentially, I'd like to hear your views on handling resource copying. Is
>> there an obvious method I've overlooked? What are other projects doing to
>> handle resources? Any ideas with respect to other methods of handling 
>> resources?
> 
> 
> You could do your resources like this:
> 
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
> 
> set(inres ${CMAKE_CURRENT_SOURCE_DIR}/myres.txt)
> set(outres ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/myres.txt)
> add_custom_command(OUTPUT "${outres}"
>   COMMAND "${CMAKE_COMMAND}" -E copy "${inres}" "${outres}")
> 
> add_library(foo foo.cpp ${outres})
> 
> The custom command will be part of building the library, and will run anytime 
> myres.txt is out-of-date.

To achieve this, there must be a dependency of ${outres} on ${inres}:

add_custom_command(OUTPUT "${outres}"
  COMMAND "${CMAKE_COMMAND}" -E copy "${inres}" "${outres}"
  DEPENDS "${inres}")

Otherwise, ${outres} is not processed anew if ${inres} changes.

Regards,

Michael
_______________________________________________
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

Reply via email to