<< May 8, 2020 | Home | May 10, 2020 >>

CMake: Copy files after build

If you need to e.g. bundle/copy data along your build you can use a call similar to this. Just make sure to select the target you want to 'target'.

Possible copy hooks are: PRE_BUILD | PRE_LINK | POST_BUILD

Single files

add_custom_command(
        TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
                ${CMAKE_CURRENT_BINARY_DIR}/config/config.yaml
                ${CMAKE_CURRENT_BINARY_DIR}/bin/config/config.yaml)

Directories:

add_custom_command(TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
                ${CMAKE_CURRENT_SOURCE_DIR}/res
                ${CMAKE_CURRENT_BINARY_DIR}/res)

More read: https://cmake.org/cmake/help/v3.0/command/add_custom_command.html

Tags :

Export this post as PDF document  Export this post to PDF document

Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!

<< May 8, 2020 | Home | May 10, 2020 >>