[英]How to set a post build command to VS project from cmake?
I need to set this post-build event in cmake我需要在 cmake 中设置此构建后事件
how to do this?这个怎么做?
I am using below command in my vs project, but I need to add it during CMake build in Cmakelists.txt我在我的 vs 项目中使用以下命令,但我需要在Cmakelists.txt中的 CMake 构建期间添加它
xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)"
I tried following but they didn't work for me VS cannot find the path我尝试跟随但它们对我不起作用VS找不到路径
How to copy DLL files into the same folder as the executable using CMake? 如何使用 CMake 将 DLL 文件复制到与可执行文件相同的文件夹中?
CMake post-build-event: copy compiled libraries CMake 构建后事件:复制已编译的库
add_custom_command(
TARGET my
POST_BUILD
COMMAND ${CMAKE_COMMAND} xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)"
)
error --> this $(ProjectDir)$(Platform)$(Configuration) not giving right path it shows x64Debug not x64\Debug错误 --> 这个 $(ProjectDir)$(Platform)$(Configuration) 没有给出正确的路径它显示 x64Debug 不是 x64\Debug
It works as explained in the above comment它的工作原理如上述评论中所述
backslash should escaped: \\
add_custom_command(TARGET my POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"$(TargetPath)"
"$(ProjectDir)$(Platform)\\$(Configuration)"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.