On 12/12/2011 04:29 PM, Totte Karlsson wrote:
>>
>> At build time:
>>
> 
>> ADD_CUSTOM_COMMAND(TARGET OneOfYourExecutables
>>      COMMAND ${CMAKE_COMMAND} -E copy_if_different
>>          <path>/<to>/input.txt $<TARGET_FILE_DIR:OneOfYourExecutables>)
>> ADD_CUSTOM_COMMAND(TARGET AnotherExecutable
>>      COMMAND ${CMAKE_COMMAND} -E copy_if_different
>>          <path>/<to>/input.txt $<TARGET_FILE_DIR:AnotherExecutable>)
>>
>> Personally, I'd prefer the latter as it's clean and quite flexible.
> 
> I decided to use
> ADD_CUSTOM_COMMAND(
> TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E
> copy_if_different
>         "P:/mtkLib/Examples/${PROJECT_NAME}/ball.mtk"
> $<TARGET_FILE_DIR:${PROJECT_NAME}>
> )
> 
> It works fine. But I have a few more questions:
> 1) How can I get rid of the absolute path in the expression for the
> source file?

Use the ${PROJECT_SOURCE_DIR} variable. It points to the directory
containing the CMakeLists.txt file with the last project() call.

> 2) when doing make clean, the file in the target file dir is not
> deleted. How to add it to 'clean'?

See the ADDITIONAL_MAKE_CLEAN_FILES directory property. However, this is
going to be somewhat tricky since you are using $<TARGET_FILE_DIR:...>
in your custom command, and AFAIK the set_directory_property command is
not aware of this notation. Do you really need ball.mtk to be in the
same directory as your output file?

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