将目录添加到不带CMakeLists.txt的CMake项目中

我有以下项目结构:

  • CMakeLists.txt(顶层)
  • 包括
  • 源文件
  • 例子
  • 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.

评论
  • (艮)悲伤
    (艮)悲伤 回复

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