简体   繁体   中英

Add directory to CMake project without CMakeLists.txt

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM