On Thu, Jan 7, 2010 at 4:00 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><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, 07 Jan 2010 15:54:33 -0600, Ryan Pavlik <<a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a>> wrote:<br>
> If you use the _LIBRARIES variable, you don't need to even mess around<br>
> with the imported targets thing<br>
<br>
</div>Dumping recursive dependencies in *_LIBRARIES causes overlinking, they<br>
should only be there when linking statically.<br>
<font color="#888888"><br>
Jed<br>
</font></blockquote></div><br>So then actually should we all be doing imported targets in our find modules then? I didn't realize it: most of the ones I looked at that come with cmake didn't use it, so I just worked around it - wrote a function that can safely remove those dupes instead :)<br>
<br>Is there any drawback (besides slightly longer code) to doing the imported targets route?<br><br>Here's that CleanLibraryList.cmake file:<br><br><br># - A smarter replacement for list(REMOVE_DUPLICATES) for library lists<br>
#<br># clean_library_list(<listvar> [<additional list items>...]) - where<br># WHATEVER_LIBRARIES is the name of a variable, such as a variable being<br># created in a Find script.<br>#<br># Removes duplicates from the list then sorts while preserving "optimized",<br>
# "debug", and "general" labeling<br>#<br># Requires CMake 2.6 or newer (uses the 'function' command)<br>#<br># Original Author:<br># 2009-2010 Ryan Pavlik <<a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a>> <<a href="mailto:abiryan@ryand.net">abiryan@ryand.net</a>><br>
# <a href="http://academic.cleardefinition.com">http://academic.cleardefinition.com</a><br># Iowa State University HCI Graduate Program/VRAC<br><br>function(clean_library_list _var)<br> # combine variable's current value with additional list items<br>
set(_work ${${_var}} ${ARGN})<br> if(_work)<br> # Turn each of optimized, debug, and general into flags<br> # prefixed on their respective library (combining list items)<br> string(REGEX REPLACE "optimized;" "1CLL%O%" _work "${_work}")<br>
string(REGEX REPLACE "debug;" "1CLL%D%" _work "${_work}")<br> string(REGEX REPLACE "general;" "1CLL%G%" _work "${_work}")<br><br> # clean up list<br>
list(REMOVE_DUPLICATES _work)<br> list(SORT _work)<br><br> # Split list items back out again: turn prefixes into the<br> # library type flags.<br> string(REGEX REPLACE "1CLL%G%" "general;" _work "${_work}")<br>
string(REGEX REPLACE "1CLL%D%" "debug;" _work "${_work}")<br> string(REGEX REPLACE "1CLL%O%" "optimized;" _work "${_work}")<br><br> # Return _work<br>
set(${_var} ${_work} PARENT_SCOPE)<br> endif()<br>endfunction()<br><br clear="all"><br>-- <br>Ryan Pavlik<br>HCI Graduate Student<br>Virtual Reality Applications Center<br>Iowa State University<br><br><a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a><br>
<a href="http://academic.cleardefinition.com">http://academic.cleardefinition.com</a><br>Internal VRAC/HCI Site: <a href="http://tinyurl.com/rpavlik">http://tinyurl.com/rpavlik</a><br>