【发布时间】:2015-02-12 09:04:39
【问题描述】:
我的 CMake 代码如下所示:
macro(macro_name target_name)
add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND MyCommand)
endmacro()
运行此程序,我收到以下消息:
CMake Warning (dev) at ... (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() must exist. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
The target name "target_name" is unknown in this context.
函数内部的相同代码效果很好,但我需要宏来处理其他事情。
CMake 政策 (http://www.cmake.org/cmake/help/v3.0/policy/CMP0040.html) 建议忽略此警告(并完全忽略添加后期构建步骤)或根据设置将其视为错误。
这:http://www.cmake.org/cmake/help/v3.0/command/macro.html 声明宏中的参数行为与函数中的行为不同。
如何正确参考宏参数来完成这项工作?
【问题讨论】:
标签: macros cmake post-build-event