1. Makefile
可以根据需要灵活选择
warning
或者error
打印相关变量
1.1 警告
$(warning xxxxx)
$(warning $(XXX))
在终端输出行号,及打印信息,不会终止编译过程
1.2 报错
$(error xxxxx)
$(error $(XXX))
在终端输出行号,及打印信息,同时终止编译过程。
2. CMakeList.txt
2.1 警告
message(WARNING "message text")
2.2 报错
# FATAL_ERROR: CMake Error, stop processing and generation.
# SEND_ERROR: CMake Error, continue processing, but skip generation.
message(FATAL_ERROR "message text")
3. 调试确认Makefile被include了两次
在需要调试的文件头部加类似以下的信息:
LGDEBUG为自定义的与Makefile中其他变量不重名的变量,component.mk为我要调试的Makefile。
ifeq ($(LGDEBUG), )
$(warning enter component.mk first time)
LGDEBUG = COMPONENT_DEBUG
else
$(error enter component.mk second time)
endif