<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta content="MSHTML 6.00.6000.16945" name="GENERATOR">
</head>
<body>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">I have come up with a partial solution to this issue by putting the add_subdirectory into a macro that is called to do the add along with
the add_depend.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">It looks for a variable of ${CMAKE_PROJECT_NAME}_BUILT in order to determine if it should add_subdirectory or just add_depend.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">The issue now is that I recieve warnings of overiding commands and ignoring old commands for the shared dependency.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">Let me clarify my earlier post.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">My top level project contains 4 projects.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">/trunk/a (Only Executable)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">/trunk/b</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">/trunk/c</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">/trunk/d</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">To Build, a requires b. b requires c. Both a and c require d.</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">In a:</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">project(a)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">set(BASEDIR /trunk)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">add_subdirectory(${BASEDIR}/b ${CMAKE_BINARY_DIR}/b)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">add_subdirectory(${BASEDIR}/d ${CMAKE_BINARY_DIR}/d)</span></font></span></span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">...</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">In b:</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">project(a)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">set(BASEDIR /trunk)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" color="#0000ff" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">add_subdirectory(${BASEDIR}/c ${CMAKE_BINARY_DIR}/c)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">...</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">In c:</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">project(a)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">set(BASEDIR /trunk)</span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" color="#0000ff" size="2"><span class="383374513-26012010"></span></font></span> </div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">add_subdirectory(${BASEDIR}/d ${CMAKE_BINARY_DIR}/d)</span></font></span></span></font></span></div>
<div dir="ltr" align="left"><span class="258391919-31072009"><font face="Arial" size="2"><span class="383374513-26012010">...</span></font></span></div>
</span></font></span></div>
</span></font></span></div>
<div><font face="Arial" size="2"></font> </div>
<div><span class="383374513-26012010"><font face="Arial" size="2">This method fails due to the same Bin dir being used for d in both c and a.</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="383374513-26012010"><font face="Arial" size="2">To solve this, I created a macro that does the following along with adding set (${CMAKE_PROJECT_NAME}_BUILT 1) to all projects</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2"></font></span> </div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">if(${_name}_BUILT)</font></span></div>
<div><span class="383374513-26012010"> <font face="Arial" color="#0000ff" size="2">
add_dependencies(${_target} ${_name})</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">else()</font></span></div>
<div><span class="383374513-26012010"> <font face="Arial" color="#0000ff" size="2">
add_subdirectory(${_src} ${_bin})</font></span></div>
<div><span class="383374513-26012010"> <font face="Arial" color="#0000ff" size="2">
add_dependencies(${_target} ${_name})</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">endif()</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2"></font></span> </div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">The issue that now appears is that project d has the following warnings when make is ran.</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">CMakeFiles/Makefile2:76051: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/all'<br>
CMakeFiles/Makefile2:64065: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/all'<br>
CMakeFiles/Makefile2:76063: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/rule'<br>
CMakeFiles/Makefile2:64077: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/rule'<br>
CMakeFiles/Makefile2:76074: warning: overriding commands for target `trunk/d/CMakeFiles/d.dir/clean'<br>
CMakeFiles/Makefile2:64088: warning: ignoring old commands for target `trunk/d/CMakeFiles/d.dir/clean'</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2"></font></span> </div>
<div><span class="383374513-26012010"><font face="Arial" color="#0000ff" size="2">What would cause this issue in the makefiles?</font></span></div>
<div><span class="383374513-26012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="383374513-26012010"><font face="Arial" size="2"></font></span> </div>
<div><br>
</div>
<div class="OutlookMessageHeader" lang="en-us" dir="ltr" align="left">
<hr tabindex="-1">
<font face="Tahoma" size="2"><b>From:</b> cmake-bounces@cmake.org [mailto:cmake-bounces@cmake.org]
<b>On Behalf Of </b>Schwartz, Philip<br>
<b>Sent:</b> Monday, January 25, 2010 4:33 PM<br>
<b>To:</b> cmake@cmake.org<br>
<b>Subject:</b> [CMake] Out of source dependencies.<br>
</font><br>
</div>
<div></div>
<div><span class="942462521-25012010"><font face="Arial" size="2">The current project that I am working on has multiple projects layered through subdirectories. The project was a conversion from traditional makefiles and when we do a cmake build from the root
of the source tree all is done correctly. The issue comes to when we try and build a single component from a out of source build directory (we are requiring out of source builds).</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2">I have found a temp solution for example</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2">/trunk/a</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2">/trunk/b</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2">/trunk/c</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2">a requires b and b requires c to build correctly. As long as they dont share dependencies, if I use add_subdirectory(src ${CMAKE_BINARY_DIR}/<project>) for each it works to build the deps as
needed. The issue is if both a and c require the another dep pulled in the same way. The error that comes up is through a policy error of CMP0013.
</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2">Yes, I could disable the policy, but would prefer a more elegant solution for the issue. Any help would be appreciated.</font></span></div>
<div><span class="942462521-25012010"><font face="Arial" size="2"></font></span> </div>
<div><span class="942462521-25012010"><font face="Arial" size="2">--Philip</font></span></div>
<br>
<hr>
<font face="Arial" size="3">This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure,
copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.<br>
</font><br>
<hr>
<font face="Arial" color="Black" size="3">This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message.
Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.<br>
</font>
</body>
</html>