Wrong header indexed in case of multiple header files located at different paths
This is a...
- [X] Bug Report
- [ ] Enhancement Request
Brief Description
Wrong header parsed by CDT Indexer in case of multiple headers located at different paths but having the same file name.
Brief Summary
For a cross-platform C/C++ project I have the following file structure inside src folder:
/src/platform1/myheader.h
/src/platform1/mysource.cpp
/src/platform2/myheader.h
/src/platform2/mysource.cpp
where the platform is selected using multiple Build Configurations (i.e. passing different args to CMake).
Given that:
- all the builds (and JSON files) are correct (e.g. when building for
platform1only/src/platform1/mysource.cppis included in the build); - the
Preprocessor Include Paths, Macros etc.menu shows correct Parser entries (e.g. only/src/platform1if I'm working onplatform1);
I see that, when opening /src/platform1/mysource.cpp file, I get Codan errors which are clearly related to /src/platform2/myheader.h (e.g. uninitialized member variable which is only declared in /src/platform2/myheader.h and not in /src/platform1/myheader.h). I think this is a bug, but I'm not sure if Indexer or plugin fault.
It is strange because when I Ctrl-click on #include "myheader.h" inside cpp file, eclipse seems to always open the correct platform-specific file. So, why does the Indexer consider the wrong header file if it's not even part of the include paths?
What is the expected behavior?
When selected Build Configuration is platform1, I would expect the Indexer to only parse header files contained into /src/platform1 (the only path present as Parser entry).
What behavior are you observing?
The Indexer seems to also parse header files not contained in any entry of the CMAKE_EXPORT_COMPILE_COMMANDS Parser, although I have set the following configuration:

Useful Information
- cmake4eclipse version: snapshot-5 from issue 117
- Which OS do you use: Windows 10 64bit
- Cmake version: 3.15.0
I could try to build a minimal project to reproduce the issue if necessary.
I see that, when opening /src/platform1/mysource.cpp file, I get Codan errors which are clearly related to /src/platform2/myheader.h (e.g. uninitialized member variable which is only declared in /src/platform2/myheader.h and not in /src/platform1/myheader.h). I think this is a bug, but I'm not sure if Indexer or plugin fault.
cmake4eclipse adds the include paths it find in the compile_commands.json file only. So I think this is a CDT issue or an issue with your cmake scripts.
I could try to build a minimal project to reproduce the issue if necessary.
Yes please.
Yes please.
Unfortunately I'm not able to reproduce the issue with a very simple project. For some reason, the Indexer seems to get confused only with large projects. However, it seems the issue is well-known (see here).
The only way to avoid this is to exclude resources from the project, and it would be useful to have it automatic (which takes me to this other issue I upvoted here).