简体   繁体   English

如何从 cmake 为 VS 项目设置构建后命令?

[英]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.

相关问题 如何在CMake中设置VS2010项目属性? - How do I set VS2010 project properties in CMake? Visual Studio:从命令行并行设置项目生成数量 - Visual Studio : set number of project build in parallel from command line 如何在 VS 中设置后期构建事件以复制所有附属程序集 - how to set post build event in VS to copy all satellite assemblies CMake 自定义后期构建步骤命令始终执行 - CMake custom post build step command always executes 在VS 2019中使用CMake,Ninja和clang构建项目 - Build project using CMake, Ninja and clang for VS 2019 如何使用cmake的命令行根据构建类型设置属性? - How to set property depending on build-type with cmake's command line? CMake set_property 命令与生成器表达式使用构建类型 - CMake set_property command with generator expressions using build type VisualStudio 2019 是否可以从 CMAKE 设置构建变量。 更一般地说,如何设置它们 - VisualStudio 2019 is it possible te set the build variables from CMAKE. And more generally how to set them up 如何使用 CMAKE 从命令行在 Windows 上构建 x86 和/或 x64? - How to build x86 and/or x64 on Windows from command line with CMAKE? 如何从 CMake 生成的 Visual Studio 项目文件为 Windows 32 位构建 libxerces-c? - How to build libxerces-c for Windows 32-bit from CMake generated Visual Studio project files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM