[CMake] [CMAKE] Handling External Libraries and Resources

Patrik Gornicz gornicz_p at hotmail.com
Wed May 26 13:42:32 EDT 2010


> Date: Sat, 15 May 2010 07:48:54 +0200
> From: mhertling at online.de
> To: cmake at cmake.org
> Subject: Re: [CMake] [CMAKE] Handling External Libraries and Resources
>
> 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

This cleans up our custom target hack quite nicely and makes this 
process more transparent to a developer writing code. It still requires a
 bunch of management within cmake but we can live with that.



Thanks for the tips,

Patrik

 		 	   		  
_________________________________________________________________
Win a $10,000 shopping spree from Hotmail! Enter now.
http://go.microsoft.com/?linkid=9729711


More information about the CMake mailing list