1

I use Wunused-parameter for my project, but I want to have it ignore 3rd party headers (headers in specific directories). Is there a way I can set this with cmake?

I'm currently setting the compiler options like this:

add_compile_options(-Wall -Wextra -pedantic -Werror -pedantic-errors -Wshadow -Wstrict-aliasing)
rhughes
  • 9,257
  • 11
  • 59
  • 87

1 Answers1

1

Compilers generally ignore warnings in system headers. So, the solution is to designate the directories where the third party headers are searched from as system include directories.

In GCC / Clang, this is achieved by using -isystem instead of -I, In Cmake, this is done by passing the argument SYSTEM to target_include_directories.

However, include dirs of third party libraries are typically added using target_link_libraries instead and unfotunately there is no way to pass SYSTEM through that directly. This can be solved with a little helper function: CMake: target_link_libraries include as SYSTEM to suppress compiler warnings.

eerorika
  • 232,697
  • 12
  • 197
  • 326