【发布时间】:2021-03-26 16:12:03
【问题描述】:
我需要在 cmake 中设置这个构建后事件
如何做到这一点?
我在我的 vs 项目中使用以下命令,但我需要在 CMake 构建期间添加它 Cmakelists.txt
xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)"
我尝试跟随但它们对我不起作用 VS 找不到路径
How to copy DLL files into the same folder as the executable using CMake?
CMake post-build-event: copy compiled libraries
add_custom_command(
TARGET my
POST_BUILD
COMMAND ${CMAKE_COMMAND} xcopy /y /d "$(TargetPath)" "$(ProjectDir)$(Platform)\$(Configuration)"
)
错误 --> 这个 $(ProjectDir)$(Platform)$(Configuration) 没有给出正确的路径它显示 x64Debug 不是 x64\Debug
【问题讨论】:
-
那么,您已经尝试将您的命令放入
add_custom_command(POST_BUILD)事件中,不是吗?请显示(添加到问题帖子中)您到底尝试了什么。如果该尝试导致错误,则也显示该错误。 -
@Tsyvarev 我已经更新了
-
反斜杠应该转义:
\\.
标签: visual-studio cmake post-build-event