atilaneves / cmake-ide

Use Emacs as a C/C++ IDE
BSD 3-Clause "New" or "Revised" License
716 stars 92 forks source link

Headers added by passing CMAKE_PREFIX_PATH are not found #198

Open Pouya-moh opened 4 years ago

Pouya-moh commented 4 years ago

Hi, and thanks for great work.

My project depends on a package that is not in the system search path so I pass its location via -DCMAKE_PREFIX_PATH:

((nil . ((cmake-ide-build-dir . "build")
         (cmake-ide-cmake-args . ("-DCMAKE_BUILD_TYPE=RelWithDebInfo" "-DCMAKE_PREFIX_PATH=~/some/user/specified/path/install/")))))

cmake-ide runs the CMakeLists.txt and if I ask, it compiles it perfectly. However, in the buffer I'm having on the fly error that the headers in that install directory cannot be found. Furthermore, rtags-completion fails to populate the backend with the contents of those headers.

I also tried Qtcreator which uses libclang and there, I faced no problem. Either case, the code compiles.

The json file correctly contains -I~/some/user/specified/path/install/include. Note the include at the end of the path which is as it is supposed to be.

Any thoughts?

atilaneves commented 4 years ago

The prefix path needs to be passed to flycheck for the on-the-fly errors to disappear. I'm not sure why said path isn't in the compilation database, or if it is, why it's not getting treated properly.

Pouya-moh commented 4 years ago

Thanks for the reply.

I'm not sure why said path isn't in the compilation database

well the compilation database does contain the path.

This is a bit strange but I did a test: I removed the (cmake-ide-build-dir . "build") so now the project is being built somewhere in /tmp. I do still get the flycheck error which impedes the autocomplete, however, after I trigger cmake-ide-compile which works fine, then all the flyckech issues dissapear and completion works as well.

atilaneves commented 4 years ago

That's... even weirder. Unless the path in the compilation db is relative? I don't know.