CLion indexer does not resolve some includes in the project directory

回眸只為那壹抹淺笑 提交于 2019-12-03 00:48:49

You need to create a CMakeLists.txt for CLion to be happy. It is enough to declare all the source files, you don't have to convert your scons (or any other build system) to cmake.

You don't even have to write the CMakeLists.txt by hand, you can ask CLion to do it:

  • File | New CMake Project from Sources... (since CLion 2019.2)
  • File | Import project ... | (older CLion)

and then point at the directory containing your project.

Now edit the generated CMakeLists.txt and add a cmake command to tell CLion where to find the includes (actually to tell the compiler, and CLion will reuse that information).

Since your source files use the include as #include "my_includes/my_own.hpp", you need to tell cmake the base directory containing directory my_includes:

include_directories(.)

Where the dot means the same directory as the one containing the CMakeLists.txt.

I tested with a project reproducing your layout and from my_src.cpp I can navigate to my_own.hpp.

Then to build you still have to use scons in a console. It is also possible to add a cmake command, add_custom_target() that will call your scons (or your make, or whatever), so that you can also navigate from CLion to the build errors.

This should be a CMake-based project to open correctly in CLion. Check CMake basics tutorial if you are new to CMake: https://www.jetbrains.com/help/clion/2016.1/quick-cmake-tutorial.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!