CLion parser can't find header file of library in docker toolchain
I'm using cmake + docker toolchain. Into docker image i've installed 3'rd party library and it's headers. Compilation and linking performs fine, but CLion editor shows that it can't find header file. Header files from standard library are detected though.
How to detect the root cause?
请先登录再写评论。
Hi Vladimir!
Have you added an include directory for this library in your CMakeLists.txt - https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html#inc-dirs?
Yes, i've already workarounded the problem in that way.
Directory with library headers resides in standard path. Isn't it strange that compiler does not warn about unknown header, whereas CLion performs directory caching only after call to target_include_directories(...)?
>Directory with library headers resides in standard path
What path is it?
How do you add the library in your CMakeList.txt?
Okey, here is my setup.
Lib path:
In file.cpp:
In CMakeLists.txt:
CLion starts to cache files from /usr/include/gmock/ only after call to target_include_directories(...). Is it expected behavior? From code configuration point of view that call is redundant in CMakeLists.txt. Right?
I've ran into the same problem as Vladimir Yu. Ivanov. I'm on a Mac if that helps.
It looks to me like when you install more libraries into a docker image, the header cache in /Users/<username>/Library/Caches/JetBrains/CLion2022.3/.docker/2022_3/Docker/<toolchain-image-name>/usr/include
does not get resynchronized, so some headers are missing for me.
It does get synchronized if I add an explicit target_include_directories like Vladimir mentioned, or if I delete this cache directory myself and click to reload cmake configuration.
For some reason clicking 'File -> Invalidate Caches' or Cmake -> gear icon -> Reset cache and reload project do not resynchronise this cache.
Now that I know it's not a big deal but I'm sure it would be a nice usability improvement if this got somehow fixed :)
For more clarification this happens to me when I'm using the aws-cpp-sdk library in an Alpine image, using the default Alpine build meta package (build-base) + cmake.
In my case the library was installed like this:
I'm using a multi-stage Docker image build if that makes any difference.
You can try updating header search paths manually by calling Tools | Resync with Remote Hosts.
I had the same issue. This fixed it for me. Thanks