[CMake] [CMAKE] Handling External Libraries and Resources
Michael Hertling
mhertling at online.de
Sat May 15 01:48:54 EDT 2010
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
More information about the CMake
mailing list