# System include path

**URL:** <https://discourse.cmake.org/t/system-include-path/1457>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [June 29, 2020, 6:56am UTC](https://discourse.cmake.org/t/system-include-path/1457 "2020-06-29T06:56:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cedric\_Schmeits](https://discourse.cmake.org/user_avatar/discourse.cmake.org/cedric_schmeits/32/711_2.png) [@Cedric\_Schmeits](https://discourse.cmake.org/u/Cedric_Schmeits)\
**Post date:** [June 29, 2020, 6:56am UTC](https://discourse.cmake.org/t/system-include-path/1457/1 "2020-06-29T06:56:31Z")

</div>

I’m currently in the process of using pclint in checking the c and c++ source files for errors. So when I have a target I want to lint the files that are the sources of that target to be processed using the pclint application. Currently I have it working so that the include folders for the target are also passed to the pclint application. This works quite oke, but one off the final errors is that the pclint application can’t find the system include files and generates errors for that.

So my question is how can I find the general system include folders for a certain target or source?  
I thought that it had to do with INTERFACE\_SYSTEM\_INCLUDE\_DIRECTORIES but when I read this out through several ways of get\_property it always returns empty.

That said it might also be relevant that I’m using a cross compiler and that sysroot has been set.

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [July 3, 2020, 10:00pm UTC](https://discourse.cmake.org/t/system-include-path/1457/2 "2020-07-03T22:00:25Z")

</div>

I have just the same problem with clang-tidy:

```auto
|| clang-tidy -header-filter=/Users/clausklein/Workspace/cpp/netkit-tftp/.* -checks=-*,cppcoreguidelines-*,cppcoreguidelines-pro-* portability-*,readability-* ,misc-*,boost-*,cert-*,misc-unused-parameters -p=/Users/clausklein/Workspace/cpp/netkit-tftp /Users/clausklein/Workspace/cpp/netkit-tftp/tftpd_test.cpp
async_tftpd_server.hpp|3 col 10| error: 'functional' file not found [clang-diagnostic-error]
|| #include <functional>
|| ^

```

I have tried to add the include path to the c++ header with:

```cmake
include_directories(SYSTEM /usr/local/include/c++/${CMAKE_CXX_COMPILER_VERSION})
# ...
target_include_directories(tftpd SYSTEM PRIVATE /usr/local/include/c++/${CMAKE_CXX_COMPILER_VERSION})

```

but cmake does suppress the second and so it is not added to compile\_commands.json file except for c targets?

```json
{
  "directory": "/Users/clausklein/Workspace/cpp/.build-netkit-tftp-Debug",
  "command": "/usr/local/opt/gcc/bin/g++-9 -DASIO_NO_DEPRECATED -DASIO_STANDALONE -DBOOST_ALL_NO_LIB -Dtftpd_EXPORTS -I/Users/clausklein/Workspace/cpp/netkit-tftp -isystem /usr/local/Cellar/boost/1.72.0_2/include -isystem /usr/local/include -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fPIC -Wall -Wextra \"-Wno-#pragma-messages\" -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -std=c++17 -o CMakeFiles/tftpd.dir/tftp_subs.o -c /Users/clausklein/Workspace/cpp/netkit-tftp/tftp_subs.cpp",
  "file": "/Users/clausklein/Workspace/cpp/netkit-tftp/tftp_subs.cpp"
},

{
  "directory": "/Users/clausklein/Workspace/cpp/.build-netkit-tftp-Debug",
  "command": "/usr/local/opt/gcc/bin/gcc-9 -isystem /usr/local/include/c++/9.3.0 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wall -Wextra \"-Wno-#pragma-messages\" -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -o tftp/CMakeFiles/tftp.dir/tftp.o -c /Users/clausklein/Workspace/cpp/netkit-tftp/tftp/tftp.c",
  "file": "/Users/clausklein/Workspace/cpp/netkit-tftp/tftp/tftp.c"
},

```

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [July 4, 2020, 9:49pm UTC](https://discourse.cmake.org/t/system-include-path/1457/3 "2020-07-04T21:49:23Z")

</div>

see too [https://gitlab.kitware.com/cmake/cmake/-/issues/20912](https://gitlab.kitware.com/cmake/cmake/-/issues/20912)

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [July 6, 2020, 4:29am UTC](https://discourse.cmake.org/t/system-include-path/1457/4 "2020-07-06T04:29:49Z")

</div>

It seem help to set `CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES`

---

<div class="post-metadata">

**Author:** ![edassis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/edassis/32/2250_2.png) [@edassis](https://discourse.cmake.org/u/edassis)\
**Post date:** [March 7, 2022, 9:13pm UTC](https://discourse.cmake.org/t/system-include-path/1457/5 "2022-03-07T21:13:47Z")

</div>

I’m using a MAC M1 12.2.1 to compile _c++_ code and my problem is similar with yours:

I use _cmake_ to build, although specified the the system include directory with `include_directories()` or `target_include_directories()` the _compile\_commands.json_ always shows the same `-isysroot` path:

```auto
[
{
  "directory": "/Users/eduardo/Documents/Repos/competitive/build",
  "command": "/opt/homebrew/bin/g++-11 -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -std=gnu++17 -o CMakeFiles/a.dir/main.cpp.o -c /Users/eduardo/Documents/Repos/competitive/main.cpp",
  "file": "/Users/eduardo/Documents/Repos/competitive/main.cpp"
}
]

```

And my LSP complains about not finding the include files putting error squiggles all over the place.

Using `CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES` solved for me:

```auto
[
{
  "directory": "/Users/eduardo/Documents/Repos/competitive/build",
  "command": "/opt/homebrew/bin/g++-11 -isystem /opt/homebrew/include/c++/11 -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -std=gnu++17 -o CMakeFiles/a.dir/main.cpp.o -c /Users/eduardo/Documents/Repos/competitive/main.cpp",
  "file": "/Users/eduardo/Documents/Repos/competitive/main.cpp"
}
]

```

More than 1 month trying to solve this until I saw your tip. Thanks!
