cmake 抑制外部库上的警告

Joa*_*cho 9 warnings cmake suppress-warnings

我在我的项目中使用 GLAD,并使用 cmake 构建所有内容。

由于这是一个外部库而不是我的代码,我想在构建时完全抑制它的警告,因为我得到了很多这些:

warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
 glad_glCullFace = ( PFNGLCULLFACEPROC ) load ( "glCullFace" );
                   ^
Run Code Online (Sandbox Code Playgroud)

我该怎么做?我可以将它包含在我的源代码中,或者使用 GLAD 的源代码做一个 add_library,不管哪种方式。

谢谢

Dru*_*umM 5

使用 SYSTEM 关键字可以避免来自系统库的警告,如下所示:

target_include_directories(target SYSTEM GLAD)
Run Code Online (Sandbox Code Playgroud)