3
votes

A project I'm working on links to Google test (gtest) as a dependency. The google test headers are included in the project though CMake's interface dependencies, using the CMakeLists included in the google test project.

target_link_libraries (our_project gtest gmock)

Some of the warning flags that we have used for our project are printing tons of warnings in google test- for instance, GCC's -Wsuggest-override. Ideally these warnings would not be printed since they originate in a library, and I think including the library headers with -isystem is the correct way to do this. However, I'm not sure how to configure CMake to use -isystem for a specified library.

Is there a way we can specify a library dependency as a system library without modifying gtest, and ignore the warnings from it?

1

1 Answers

1
votes

target_include_directories() provides a SYSTEM option which does what you want. Or, if the target is an imported library target, populate the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES property as opposed to the INTERFACE_INCLUDE_DIRECTORIES property.