Cmake: use add_custom_command to copy binary to specific location failed when location doesn't exist

后端 未结 1 1041
长情又很酷
长情又很酷 2020-12-16 17:27

I\'m trying to copy all the binaries generated by cmake to a specific directory. I don\'t want to use EXECUTABLE_OUTPUT_PATH, keeping them in the building tree make developm

相关标签:
1条回答
  • 2020-12-16 18:18

    Just make sure that the target location "bin" exists before invoking the copy command, i.e.:

    ADD_CUSTOM_COMMAND(TARGET example
              POST_BUILD
              COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}
              COMMAND ${CMAKE_COMMAND} -E copy ${EXAMPLE_BIN_NAME} ${PROJECT_BINARY_DIR}/.
    )
    
    0 讨论(0)
提交回复
热议问题