每次构建后,如何使CLion自动将编译的可执行文件复制到指定目录?
由于CLion使用CMake,所以我猜应该可以通过CMakeLists.txt文件中的某些CMake命令来实现。但是我不知道该怎么做。
最佳答案
我不了解CLion,但通常可以使用以下命令将其作为post-build step添加到CMake中的executable target中:
add_executable(MyExe ...)
add_custom_command(TARGET MyExe
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:MyExe> SomeOtherDir)
参见例如Copy target file to another location in a post build step in CMake