Project can be compiled correctly, but highlighting, completion, refactorings, etc. in CLion are not working. CLion fails to find some of my classes. What to do?

Most probably CLion is unaware of some files in your project (these files are grayed out in the project tree):

CLion gets this information from CMakeLists.txt files in the following way:

set(SOURCE_FILES main.cpp)
add_executable(my_exec ${SOURCE_FILES})

This is how CLion now knows that main.cpp is included in your project. Before v2018.2, header files (in case their names differ from the appropriate .cpp files already added to the SOURCE_FILES variable) should also be included in the project in that way. Starting from 2018.2, CLion automatically treats included files as project files.

Since CLion 1.5 EAP there is also a new feature ‘Mark Directory As’ that allows to mark directories as:

  • Excluded
  • Libraries
  • Project sources and headers

Read more about use cases and details in our blog.

 

11 out of 53 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request