# CMake -\> Eclipse CDT4: how to prevent Eclipse from indexing files not in project?

**URL:** https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521
**Category:** Usage
**Created:** [January 18, 2020, 3:25pm UTC](https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521 "2020-01-18T15:25:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [January 18, 2020, 3:25pm UTC](https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521/1 "2020-01-18T15:25:22Z")

</div>

I’m not sure if this is just a shortcoming of Eclipse or not.

I have a large source tree and also a CMake project that uses a small fraction of the source files in that tree. When I generate for Eclipse CDT4 and import the project, the Eclipse indexer is clearly indexing files that aren’t referenced in the CMake project. Is there a way to control this with CMake? I would have expected Eclipse to only index the specific project files. There is an Eclipse workspace setting:  
Properties-\>c/c++ general-\>Indexer-\>“Index source files not included in the build” which I have disabled, but it still indexes sources not included in the CMake project.

Any help appreciated.

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [January 21, 2020, 5:44pm UTC](https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521/2 "2020-01-21T17:44:59Z")

</div>

I wanted to clarify one thing from my post: the CMake project enumerates all source files explicitly - it does not add sources by file globbing or recursive file globbing. To me this should result in an Eclipse project that is limited to the source files mentioned, but the indexer still tries to index every cpp from the top-level folder on down recursively.

---

<div class="post-metadata">

### Author: ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)
#### Post date: [January 25, 2020, 10:00am UTC](https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521/3 "2020-01-25T10:00:07Z")

</div>

AFAIK, you cannot prevent Eclipse from indexing files that are in the source tree but not referenced in the CMake project.

See the following threads for more details:

- [https://cmake.org/pipermail/cmake/2019-April/069254.html](https://cmake.org/pipermail/cmake/2019-April/069254.html)
- [https://gitlab.kitware.com/cmake/cmake/issues/19107](https://gitlab.kitware.com/cmake/cmake/issues/19107)
- [https://bugs.eclipse.org/bugs/show\_bug.cgi?id=545905](https://bugs.eclipse.org/bugs/show_bug.cgi?id=545905)

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [January 29, 2020, 3:30pm UTC](https://discourse.cmake.org/t/cmake-eclipse-cdt4-how-to-prevent-eclipse-from-indexing-files-not-in-project/521/4 "2020-01-29T15:30:16Z")

</div>

Thanks - those links are very helpful.
