CLion fails to find some of my headers. Where does it search for them?

CLion searches through the same places CMake does. Set the include_directories variable in CMake to provide the headers path to the IDE. More details on CMake configuration can be found in our Quick CMake Tutorial.

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.

 

 

1 comment

I hope this helps.

cmake_minimum_required(VERSION 3.6)
project(untitled)

set(CMAKE_CXX_STANDARD 11)

#Set your directories. The dot representes the root application folder.
#Thus my the path to my domain folder:
set(APP_DOMAIN ./domain)
set(APP_CALC ./calc)

#Include the directories and now your cpp files will recognize your headers
include_directories(${APP_DOMAIN})
include_directories(${APP_CALC})

set(
SOURCE_FILES
main.cpp
${APP_DOMAIN}/person.h
${APP_DOMAIN}/person.cpp
${APP_CALC}/add.h
${APP_CALC}/add.cpp
)
add_executable(untitled ${SOURCE_FILES})

#CHEARS!
0

Please sign in to leave a comment.

Have more questions?

Submit a request