Little background
I was having the same problem, albeit the project was not header-only, nevertheless, the open files from inc
folder were throwing the aforementioned warning, even though the CMake file clearly marked that folder to be include_directory
.
*.hpp files do not belong to ${SOURCE}
include_directories("${PROJECT_SOURCE_DIR}/inc/") add_subdirectory(src) add_executable(${EXECUTABLE_NAME} main.cpp ${SOURCE})
Since this is a perfectly valid CMake file and adding the include files to source files is not idiomatic, I did not want to amend the CMake file.
The solution
As described on the official JetBrains Forum, the CMake file is indeed valid and the warning is shown because of the inability of CLion to properly index header files. The suggested workaround extracted from the link is to right-click the folder and Mark directory as
| Library Files
/Project Sources and Headers
.
So, this header isn’t includes in executables and CLion notifies you that some code insight features might not work properly. As workaround you can use “Mark directory as” Library Files/Project Source and Headers for folder.