gpt4 book ai didi

visual-studio-2010 - CMake添加VS2010项目自定义构建事件

转载 作者:行者123 更新时间:2023-12-04 03:09:22 25 4
gpt4 key购买 nike

有没有一种方法可以将CMake设置为生成其中包含Pre Build或Post Build事件的VS2010 Project文件?

谢谢。

最佳答案

从CMake文档中:

add_custom_command(TARGET target
PRE_BUILD | PRE_LINK | POST_BUILD`
COMMAND command1 [ARGS] [args1...]
[COMMAND command2 [ARGS] [args2...] ...]
[WORKING_DIRECTORY dir]
[COMMENT comment] [VERBATIM])

This defines a new command that will be associated with building the specified
target. When the command will happen is determined by which of the following
is specified:

PRE_BUILD - run before all other dependencies
PRE_LINK - run after other dependencies
POST_BUILD - run after the target has been built

Note that the PRE_BUILD option is only supported on Visual Studio 7 or later.
For all other generators PRE_BUILD will be treated as PRE_LINK.

例如,如果您的目标名为 MyProject,并且您想在建筑物之后运行带有参数 SomeCommand-1 -2命令,请在或 add_executable调用的之后添加以下行 ,因为必须定义目标:
add_custom_command(TARGET MyProject
POST_BUILD
COMMAND SomeCommand ARGS "-1 -2"
COMMENT "Running SomeCommand")

有关如何使用add_library的更多详细信息,请参见https://cmake.org/cmake/help/v2.8.8/cmake.html#command:add_custom_command

关于visual-studio-2010 - CMake添加VS2010项目自定义构建事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7988297/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com