Skip to content

make IDEs aware of the headers

Andrey Butirsky requested to merge work/bam/add_headers into master

Nowadays, it's generally recommended to add headers alongside with sources in CMake:

note that .h header files were specified as sources too, not just the .cpp implementation files. Headers listed as sources don’t get compiled directly on their own, but the effect of adding them is for the benefit of IDE generators like Visual Studio, Xcode, Qt Creator, etc. This causes those headers to be listed in the project’s file list within the IDE, even if no source file refers to it via #include. This can make those headers easier to find during development and potentially aid things like refactoring functionality, etc.

https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/

Recent Qt Creator depends on it heavily:

This means that the header files will get the same treatment as the source files.

  • clang-tidy and clazy will be able to analyze them
  • The TODO plugin can find the TODOs in header files
  • The Test plugin can find the Google Tests defined in header files

https://www.qt.io/blog/qt-creator-6-cmake-update
In my personal observations it should also help with source/header jumps as it sometimes doesn't work reliably otherwise.

Other IDEs should benefit too.

Edited by Andrey Butirsky

Merge request reports