我运行cmake
如下:
cmake . -G Ninja -D CMAKE_PREFIX_PATH=~/libs/QT6.5d -DCMAKE_WARN_DEPRECATED=OFF
但在使用 GCC12 构建我的项目时收到以下警告:
/usr/include/c++/12/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
32 | #warning \
| ^~~~~~~
为什么没有CMAKE_WARN_DEPRECATED
效果?
运行 cmake-Wno-deprecated
也没有帮助。
cmake . -G Ninja -D CMAKE_PREFIX_PATH=~/libs/QT6.5d -Wno-deprecated
CMAKE_WARN_DEPRECATED
控制CMake警告(由 发出的警告message(DEPRECATION ...)
),传递-Wno-deprecated
给 CMake 的是用于将此变量设置为 的别名OFF
。您的弃用警告是由编译器发出的,您需要将
-Wno-deprecated
标志传递给编译器。一种方法是使用target_compile_options
: