Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 Cmake添加VS2010项目自定义生成事件_Visual Studio 2010_Cmake - Fatal编程技术网

Visual studio 2010 Cmake添加VS2010项目自定义生成事件

Visual studio 2010 Cmake添加VS2010项目自定义生成事件,visual-studio-2010,cmake,Visual Studio 2010,Cmake,是否有一种方法可以设置CMake以生成包含预构建或后构建事件的VS2010项目文件 谢谢。来自CMake文档: add_custom_command(TARGET target PRE_BUILD | PRE_LINK | POST_BUILD` COMMAND command1 [ARGS] [args1...] [COMMAND command2 [ARGS] [args2...] ...]

是否有一种方法可以设置CMake以生成包含预构建或后构建事件的VS2010项目文件


谢谢。

来自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
,并且您希望在构建后运行带有参数
-1-2
的命令
SomeCommand
,则在
add_executable
add_library
调用后添加以下行,因为必须定义目标:

add_custom_command(TARGET MyProject
                   POST_BUILD
                   COMMAND SomeCommand ARGS "-1 -2"
                   COMMENT "Running SomeCommand")

有关如何使用
add_custom_command()

结构良好且非常有用的答案的详细信息,请参阅:D