Hello Tyler,<br><br>Please find my comments below.<br>
<br><div class="gmail_quote">2009/5/28 Tyler Roscoe <span dir="ltr"><<a href="mailto:tyler@cryptio.net">tyler@cryptio.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Thu, May 28, 2009 at 08:56:04PM +0300, Dmytro Ovdiienko wrote:<br>
> 1. We have two projects A and B.<br>
> 2. Project A is stored to <root>/A<br>
> 3. Project B is stored to <root>/B<br>
> 4. Project A depends on B.<br>
> 5. Project B depends on A. (please don't ask me why:) )<br>
> 6. There is CMakeLists.txt in the <root><br>
<br>
</div>If A and B really depend on each other, I don't know how you would ever<br>
expect to build them, nor how you would expect CMake to handle this<br>
case.<br>
</blockquote><div><br>That was just a sample. CMake can build it correctly, if you specify full path to the include directlry.<br><br>
If you root CMakeLists.txt declares ROOT_PRJ you can write following in the A project.<br>
<br>
INCLUDE_DIRECTORIES(<br>
${ROOT_PRJ_SOURCE_DIR}/B<br>
)<br>
<br>
And following in the B project<br>
<br>
INCLUDE_DIRECTORIES(<br>
${ROOT_PRJ_SOURCE_DIR}/A<br>
)<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
But from your Lists below it appears that they don't really depend on<br>
one another, in a "target A must be built before target B" sense, but<br>
simply that they use headers from each other's source directories?<br>
<div class="im"></div></blockquote><div><br>A and B are static libraries. The order static libraries building has no mater.<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> #####################################<br>
> # Project A<br>
> #####################################<br>
> SET (PROJECT_NAME A )<br>
> PROJECT (${PROJECT_NAME})<br>
><br>
> INCLUDE_DIRECTORIES(<br>
> ${B_SOURCE_DIR}<br>
> )<br>
><br>
> FILE (GLOB ${PROJECT_NAME}_SOURCE_LIST<br>
> *.cpp<br>
> )<br>
><br>
> ADD_LIBRARY (${PROJECT_NAME} ${${PROJECT_NAME}_SOURCE_LIST})<br>
><br>
> #####################################<br>
> # Project B<br>
> #####################################<br>
> SET (PROJECT_NAME B )<br>
> PROJECT (${PROJECT_NAME})<br>
><br>
> INCLUDE_DIRECTORIES(<br>
> ${A_SOURCE_DIR}<br>
> )<br>
><br>
> FILE (GLOB ${PROJECT_NAME}_SOURCE_LIST<br>
> *.cpp<br>
> )<br>
><br>
> ADD_LIBRARY (${PROJECT_NAME} ${${PROJECT_NAME}_SOURCE_LIST})<br>
><br>
><br>
> And now we generate the project files and check Additional Includes<br>
> Directories of the A project.<br>
><br>
> Expected it is equal to <root>/B.<br>
> But in fact it is empty.<br>
<br>
</div>Is ${B_SOURCE_DIR} defined in the CMakeLists for project A?<br>
<div class="im"></div></blockquote><div><br>It is defined if B folder is processed before A folder. But then A_SOURCE_DIR is not defined in the B project (circular dependency)<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
> The other side of this problem is you have to write ADD_SUBDIRECTORY<br>
> commands in specific order. IMHO it is inconvenient.<br>
<br>
</div>CMakeLists are essentially a scripting language, so of course order<br>
matters. What would you propose instead?<br>
<font color="#888888"></font></blockquote><div><br>But... why does TARGET_LINK_LIBRARIES work correctly? You can pass not loaded-yet project name to TARGET_LINK_LIBRARIES.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<font color="#888888"><br>
tyler<br>
</font></blockquote></div><br>