【发布时间】:2021-07-11 03:19:02
【问题描述】:
我是 cmake 的新手,所以在前面,我很抱歉这个问题太基础了..
问题是,
我在#ifdef DEBUG 下有日志,我只想为调试构建打印这些日志。
类似这样的..
void func () {
// some code here
#ifdef DEBUG
print_log(...) // this portion should execute only for debug builds
#endif
// some code here
}
如何使用 cmake 实现这一点?
我已经看过#ifdef DEBUG with CMake independent from platform 和cmakelists debug flag not executing code within "ifdef DEBUG",这里的建议似乎对我不起作用。
(项目在Linux平台上)
【问题讨论】:
-
您说对问题stackoverflow.com/questions/8591762/… 的建议对您不起作用,但您的回答重复了that answer 的方法。
-
你能指定你使用的是哪个版本的 CMake 吗?因为会影响可供使用的选项。