0
我的CMake的代碼中的CMake add_custom_command如下所示:運行此的宏觀
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指出宏中的參數行爲與函數中的行爲不同。
如何正確引用宏參數來實現這個功能?
創建http://sscce.org/可幫助您發現此類問題。 – steveire 2015-02-13 18:35:18
你可以複製粘貼整個解決方案嗎?這個答案有點無用。 – TarmoPikaro 2017-08-03 11:59:05