PDA

View Full Version : Qt Creator Cmake-C++-Project: Includes in header files not found by the preprocessor



wychmaster
19th September 2016, 16:42
Hello,

I have the following problem:

I got a new computer and installed everything to continue working on an open source project. The project itself is a CMake project in C++. The data is located in a path like the following:

ProjectDir/src/SomeName

In the main CMakeFile, located in "ProjectDir", we have the line:

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)

So we can write something like

#include "SomeName/AFile.h"

Basically we get rid of the "src" in all the include-paths. This was working fine on other computers but now I have the problem, that QtCreator underlines every include and when hovering the mouse over it, it says: "No such file or directory".
I can compile the code without any issues, but the problem is, that the automatic code completion does not work anymore, which is really annoying. This error only occurs in header files. In cpp files, everything is fine. If I type the full path (with "src"), then Qt creator finds the included headers, but then it does not compile anymore, because the projects root directory is not meant to be an include directory. Is this some kind of bug in the current version or have I messed up some configurations?

My QtCreator version is 4.1

Greetings

daviddoria
17th November 2016, 14:22
I have exactly the same problem using QtCreator 4.1.0. The project builds fine, but the parser can't find some of my 3rd party library includes so auto-completion doesn't work. I even very explicitly wrote (in the subdirectory's CMakeList.txt where the problem is occuring):

include_directories(/home/doria/build/HDR-EXT/Install/include/eigen3)

and then when I check the code model that path is not in the "Project Parts -> Header Paths"