[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] add_library/add_executable ordering
From:       Hai Nguyen <chaoticbob () gmail ! com>
Date:       2009-06-26 2:13:29
Message-ID: 5c89f0eb0906251913l5ce0daabgf4c6f82a5a22e638 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Apologies. I found the error. I had used two variables to refer to the
library name and the dependency - thinking they were the same thing. There
was a mixup between the names due to using set_target_properties to change
the alter the prefix.

- Hai

On Wed, Jun 24, 2009 at 6:56 PM, Bill Hoffman <bill.hoffman@kitware.com>wrote:

> Tyler Roscoe wrote:
>
>> On Wed, Jun 24, 2009 at 03:30:33PM -0700, Hai Nguyen wrote:
>>
>>> add_library( libB ... )
>>> add_executable( ExecB ... )
>>> target_link_libraries( ExecB libB )
>>>
>>> but the build order now is: ExecB, libB
>>>
>>> I'm getting link errors because libB doesn't exist yet. If I comment out
>>> the
>>> ExecB stuff, it builds libB.
>>>
>>> Can someone give me a clue on what criteria CMake is using to determine
>>> what
>>> builds first?
>>>
>>
>> I think the order is undefined unless there are dependencies to resolve.
>>
>> I'm a litle surprised that your B example doesn't work, since I thought
>> CMake was smart enough to notice that execB needs libB and would thus
>> build libB first.
>>
>> Anyway, the way to get the correct build order is by using
>> add_dependencies(). If you do add_dependencies(execB libB) then
>> everything should work as expected.
>>
>>
> I don't think your example is complete.   That should work fine, and you do
> not need add_dependencies ever for library to executable stuff.
>
> -Bill
>

[Attachment #5 (text/html)]

Apologies. I found the error. I had used two variables to refer to the library name \
and the dependency - thinking they were the same thing. There was a mixup between the \
names due to using set_target_properties to change the alter the prefix. <br> <br>- \
Hai<br><br><div class="gmail_quote">On Wed, Jun 24, 2009 at 6:56 PM, Bill Hoffman \
<span dir="ltr">&lt;<a \
href="mailto:bill.hoffman@kitware.com">bill.hoffman@kitware.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div><div></div><div \
class="h5">Tyler Roscoe wrote:<br> <blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> On Wed, Jun 24, 2009 at 03:30:33PM -0700, Hai Nguyen wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> add_library( libB ... )<br>
add_executable( ExecB ... )<br>
target_link_libraries( ExecB libB )<br>
<br>
but the build order now is: ExecB, libB<br>
<br>
I&#39;m getting link errors because libB doesn&#39;t exist yet. If I comment out \
the<br> ExecB stuff, it builds libB.<br>
<br>
Can someone give me a clue on what criteria CMake is using to determine what<br>
builds first?<br>
</blockquote>
<br>
I think the order is undefined unless there are dependencies to resolve.<br>
<br>
I&#39;m a litle surprised that your B example doesn&#39;t work, since I thought<br>
CMake was smart enough to notice that execB needs libB and would thus<br>
build libB first.<br>
<br>
Anyway, the way to get the correct build order is by using<br>
add_dependencies(). If you do add_dependencies(execB libB) then<br>
everything should work as expected.<br>
<br>
</blockquote>
<br></div></div>
I don&#39;t think your example is complete.   That should work fine, and you do not \
need add_dependencies ever for library to executable stuff.<br><font color="#888888"> \
                <br>
-Bill<br>
</font></blockquote></div><br>



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic