Qt autogenerated header not found
已回答
I'm using CLion with a Qt CMake project which uses moc to generate header files from xml forms in the output directory - and these headers are #included in the source code.
I can compile my code fine in CLion, but it's automated inspection fails to locate the header in the output directory. How can I fix this?
请先登录再写评论。
Hello!
Is the output directory added in the CMakeLists.txt (https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html#inc-dirs)?
I don't think so - because the output directory is controlled by CLion and not something that is relevant to CMakeLists.txt, right?
How do you include these headers in the source code? Is it
#include "some_header.h"or is it#include "<>/some_header.h"? What error do you get in CLion?It's included as
#include "some_header.h"and CLion is unable to find it. The file in question is https://github.com/Mudlet/Mudlet/blob/development/src/dlgMapper.cpp.Thanks for the link! Are you on Linux?
I'm on macOS, unfortunately, and therefore can't test it on my side properly at the moment (this guide tells me to build Mudlet using Makefiles, not CMake). It will take some time to test this with CMake on Ubuntu.
P.S. Just interesting information: as part of testing I executed
qmake ../src/mudlet.proaccording to the instruction and then generated a compilation database usingcompiledb make -j `sysctl -n hw.ncpu`. I opened this compilation database in CLion and all symbols in dlgMapper.cpp were resolved correctly:We also have CMake support on macOS (see Travis CI), could you try the CMake files?
Vadim, thank you for the information.
I cloned the repo in CLion 2020.1 EAP, the project was loaded successfully:
In dlgMapper.cpp I saw lots of unresolved code (which is expected):
I tried to build the project (Build | Build Project). Build failed (I don't understand why, since Zzip was found during the project loading):
Nevertheless I got the generated headers in cmake-build-debug/src/mudlet_autogen/include. I did File | Invalidate Caches / Restart and the errors were gone:
Could you please try calling File | Invalidate Caches / Restart after the build?
That worked! Thanks!
I'm glad it worked!