CLion 2019.1 Help

Manage Project Files

Included files

When you include header or source files located under the project root into any project file, CLion treats them as project files as well. You do not need to list such includes in CMakeLists.txt directly to get full code insight and refactoring functionality for them. Note that standard or third-party libraries located outside of the project root are not affected.

Non-project files

When a source or header file is not included in any of the project files or CMake targets, and is not located under the source or library roots, CLion notifies you about it:

cl fileWIldMessage
You can experience an incorrect behavior of such features like syntax highlighting, refactoring, code navigation etc. for such a file until you specify that file as a project one explicitly. To do that use one of the following approaches:

  1. When the source files that don't belong to any target are located within the project root, you should add them to a target. Use add_executable() or add_library() CMake commands depending on the target type. Let's consider it for our example.
    The above screenshot reflects condition when add executable() contains only the main.cpp Header1.h Header2.h files and knows nothing about add.cpp. Here, you should add the non-project sources to the list of source files, as follows:

    add_executable (TestProject main.cpp Header1.h Header2.cpp add.cpp)

  2. When a directory that contains the non-project library sources is located within the project root, you can mark this directory as a library: in the Project tool window, right click the desired directory and select Mark Directory As | Library Files from the context menu.

  3. For the library files located outside the project root, specify the header search paths so that the IDE can index the respective directories and provide code completion and navigation facilities on #include statements:

    include_directories( ${MY_EXTERNAL_SOURCE__DIR})
    For more details, refer to our Quick CMake Tutorial.

Upon any of these actions, the system will prompt you to reload CMake project if automatic reload is not enabled.

Last modified: 24 July 2019