add_custom_command的基本语法介绍
时间: 2023-06-22 11:24:10 浏览: 87
add_custom_command是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])
```
其中,TARGET指定要应用自定义命令的目标,PRE_BUILD、PRE_LINK、POST_BUILD表示自定义命令在何时执行,COMMAND表示要执行的命令及其参数,WORKING_DIRECTORY指定命令执行的工作目录,COMMENT可以添加注释,VERBATIM表示是否将所有参数都原样传递给命令。
例如,以下命令将在编译目标my_target之前执行一个自定义命令:
```
add_custom_command(TARGET my_target
PRE_BUILD
COMMAND echo "Custom command executed before build")
```
阅读全文
相关推荐
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)