Let's suppose we have an existing Visual Studio 2019 solution that can't be generated from scratch with another tool, e.g. CMake.
The solution contains three projects: A, B and C, each containing only one file, this is a minimal example:
/// Project A, A.hpp
// content irrelevant
/// Project B, B.hpp
#include <A.hpp> // B's public interface includes A's header
/// Project C.cpp
#include <B.hpp> // C requires B's header, which includes A's header, to compile
Being used to CMake's "target-based" approach, I naively thought that I could handle things if:
- B references A,
- C references B
In this case however, C only consumes B's include paths, but it does not consume A's include paths. The C therefore does not compile.
The "workaround" which just "makes it work" is obvious: add A's include paths to C and it will compile. But we know that this scales horribly when number of project grows:
> /// Project C2, C2.cpp
> #include <B.hpp> // requires B interface to compile
> /// Project C3, C3.cpp
> #include <B.hpp> // requires B interface to compile
> /// Project C4, C5, ... and on and on
Instead of having to having to specify the needs of B's interface across many projects, I am seeking what CMake offers: define the requirements (in my case: include paths) of B in B project itself and that's it.
My question is: how to achieve this entirely from within the Visual Studio 2019 IDE?