Hi,<div><br></div><div>I realize there's another post on the list where another user was asking relatively the same question, but this specific issue was never addressed.</div><div><br></div><div>What I'm trying to do is specify include directories on a per-project basis. I'm avoiding the monolithic shared include directories approach, where a manually managed list of include directories are provided in a call to include_directories() at the root source level (CMAKE_SOURCE_DIR).</div>
<div><br></div><div>Instead, I'm assigning include directories returned by find_package() to each project. Furthermore, the include directories of any dependent projects must be included in this list. As you can see, this is recursive.</div>
<div><br></div><div>For example, let's assume I have 3 projects named A, B, and C. Project A depends on B, and B depends on C.</div><div><br></div><div>A includes -> C:\foo</div><div>B includes -> C:\bar</div><div>
C includes -> C:\baz</div><div><br></div><div>When I process the includes for project A, I flatten the hierarchical list of includes into a list:</div><div>C:\foo;C:\bar;C:\baz</div><div><br></div><div>These become my include directories for A. I do this because A may be using header files from project B, and in B's header files may be including headers from C:\bar. For this reason, this is required in order for A to compile.</div>
<div><br></div><div>The issue is that I cannot do this as I process each project. This is because A is processed before B, and I cannot obtain B's include directories from A until B has been processed. So this obviously has to have 2 passes.</div>
<div><br></div><div>The first pass involves creating all of the projects and defining internal cache variables for each project that define their dependencies and includes. So project A would have a cache variable that looks like this:</div>
<div><br></div><div>A_INCLUDE_DIRS = C:\foo;B</div><div><br></div><div>The list has 2 types of items in it. First we list the include directories for A. At the end, we append the list of targets that A depends on. In this case, it's B. Project B's variable looks like this:</div>
<div><br></div><div>B_INCLUDE_DIRS = C:\bar;C</div><div><br></div><div>You get the picture now...</div><div><br></div><div>This allows me to recursively process the dependencies for A.</div><div><br></div><div>The first pass involves all of these cache variables getting defined. Once they're all defined, we now have all the information prepared and we can now perform the recursion to obtain the dependencies for A. The problem is, I can't set the dependencies for A now that we're no longer processing A's CMakeLists.txt file. Pass 2 takes place in the root CMakeLists after all of the add_subdirectory() calls have been made. If there were only a way for me to call set_target_properties( INCLUDE_DIRECTORIES ) of some sort, this could be done. However, INCLUDE_DIRECTORIES property is read-only according to the documentation. In addition, the INCLUDE_DIRECTORIES property is a directory specific property and not a property for targets, which further complicates this process.</div>
<div><br></div><div>What do you guys recommend? I like my approach to solving this problem, it's just that I can't do the steps required in my 2nd pass (Post-processing phase) in order to set the include directories on my projects (targets).</div>