Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include CMake project dependency include directories with -isystem

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?

like image 848
leecbaker Avatar asked Nov 02 '25 01:11

leecbaker


1 Answers

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.

like image 141
Daniel Schepler Avatar answered Nov 04 '25 03:11

Daniel Schepler