# Google Test System Includes

**URL:** <https://discourse.cmake.org/t/google-test-system-includes/1230>\
**Category:** Code\
**Created:** [May 18, 2020, 7:50pm UTC](https://discourse.cmake.org/t/google-test-system-includes/1230 "2020-05-18T19:50:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)\
**Post date:** [May 18, 2020, 7:50pm UTC](https://discourse.cmake.org/t/google-test-system-includes/1230/1 "2020-05-18T19:50:32Z")

</div>

Google test is using system interface includes. This does not work for my project/build, so I am trying to not have those interface includes be `-isystem`. I did the following…

```auto
set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
add_subdirectory(googletest)

```

Instead I’ve had to resort to just wiping out the system directories.

```auto
set_target_properties(gmock gtest PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")

```

Unfortunately even clearing the target properties explicitly, system includes are still showing up…

Note this set and add\_subdirectory is before adding my other targets as well. However, the `INTERFACE` includes of google test are still being used as `-isystem`. Any idea why?

---

<div class="post-metadata">

**Author:** ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)\
**Post date:** [May 20, 2020, 10:41pm UTC](https://discourse.cmake.org/t/google-test-system-includes/1230/2 "2020-05-20T22:41:45Z")

</div>

After using

```auto
set_target_properties(gmock gtest gtest_main gmock_main PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")

```

My issue seems to be resolved. But I still wonder why `CMAKE_NO_SYSTEM_FROM_IMPORTED` wasn’t working?

---

<div class="post-metadata">

**Author:** ![Tobias\_Rittweiler](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tobias_rittweiler/32/732_2.png) [@Tobias\_Rittweiler](https://discourse.cmake.org/u/Tobias_Rittweiler)\
**Post date:** [July 8, 2020, 6:30am UTC](https://discourse.cmake.org/t/google-test-system-includes/1230/3 "2020-07-08T06:30:20Z")

</div>

The variable governs the treatment of include directories of imported targets. Imported targets are usually created behind the scenes of `find_package()` and you use such imported targets by means of `target_link_libraries()`. In your case, you used `add_subdirectory()` which, essentially, does what `googletest/CMakeLists.txt` does and that does not involve imported targets.

See [https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#imported-targets](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#imported-targets) to learn more about imported targets.
