# ${MPI\_C\_INCLUDE\_DIRS} not working when the compiler is also set to mpicc

**URL:** https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697
**Category:** Usage
**Tags:** os:linux, os:windows
**Created:** [October 7, 2024, 3:50am UTC](https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697 "2024-10-07T03:50:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![abhinavsns](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhinavsns/32/4994_2.png) [@abhinavsns](https://discourse.cmake.org/u/abhinavsns)
#### Post date: [October 7, 2024, 3:50am UTC](https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697/1 "2024-10-07T03:50:46Z")

</div>

I have a CMake Project where I specify to find the include dirs using

```auto
target_include_directories (project PUBLIC ${MPI_C_INCLUDE_DIRS})

```

The following message results in an empty output if I set `-DCMAKE_C_COMPILER=/path/to/mpicc`

`message(STATUS "MPI Include directories : ${MPI_C_INCLUDE_DIRS}")`

but results in the correct directory if the compiler is set to gcc  
`-DCMAKE_C_COMPILER=/path/to/gcc`

Any advice will be really helpful. The behavior is reproduced on cmake 3.22 on windows subsystem for linux and also on fedora.

---

<div class="post-metadata">

### Author: ![abhinavsns](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abhinavsns/32/4994_2.png) [@abhinavsns](https://discourse.cmake.org/u/abhinavsns)
#### Post date: [October 7, 2024, 3:55am UTC](https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697/2 "2024-10-07T03:55:49Z")

</div>

Another interesting thing I just noted is that when using mpicc, the cmake config command outputs  
`-- Include directory /home/user/.local/MPI/include does not exist`

but infact it does exists indeed and is found when the compiler is set to gcc.
