Add directory to CMake project without CMakeLists.txt

Viewed 433

I have the following project structure:

  • CMakeLists.txt (top level)
  • include
    • source.h
  • examples
    • CMakeLists.txt
    • example.cpp
  • src
    • CMakeLists.txt
    • source.cpp

Top level CMakeLists.txt includes both src and examples using add_subdirectory. I want to do the same with include directory. I have no problem using the header files from include. What I want is to be able to see include directory in my IDE. Currently, QtCreator doesn't show include directory if I open the top level CMake file with it.

I know that I can add dummy CMakeLists.txt but that's a bit meh. Don't want to do this for code readers sanity sake.

1 Answers

add include_directories(include/) in your toplevel CMakeLists.txt just before using add_subdirectory

Related