Beginner: Difficulty understanding CMake impact on include statements

If you just include it as-is - yes, it would require to use B/some_class_in_B.h even for .cpp files inside B folder.

If you want files inside B to refer to some_class_in_B.h without B prefix, you can also add as a private include directoryCMAKE_CURRENT_SOURCE_DIR - it’s the same as CMAKE_SOURCE_DIR, but for the current subdirectory, e.g. for B/CMakeLists.txt it’s B/, for C/CMakelists.txt it’s C, etc.

Though it may get confusing - e.g. if C includes B/some_class_in_B.h, then some_class_in_B.h has to refer to other headers in B by usingB/ prefix to make them includable for C.

1 Like