<div dir="ltr">target_link_libraries( final_project library )  ?</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 18, 2015 at 11:29 AM, Ette, Anthony (CDS) <span dir="ltr"><<a href="mailto:Anthony.R.Ette@controlsdata.com" target="_blank">Anthony.R.Ette@controlsdata.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Given that add_library() produces a unique filename per platform (the “<span style="color:black">actual file name of the library built is constructed based on conventions of the native platform (such as
</span><span><span style="color:black;background:#ecf0f3">lib<name>.a</span></span><span style="color:black"> or</span><span><span style="color:black;background:#ecf0f3"><name>.lib”</span></span><span style="color:black">), how does
 one add the library to the final application without having to deal with the filename difference?  In other words, I’ve got one library that, by default, produces ‘libtest.a’ on Linux and ‘test.lib’ on Windows.  How can I add this imported library into the
 final application in a cross platform manner?  I know I can specify two different imported locations (see below), but it seems odd to me that Cmake – the cross-platform build env generator – doesn’t have a better native way of dealing with this….<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">The snippet below will work, but just seems wrong given the nature of what CMake is intended to do…is there a better way that I’m missing?!  If not, can I request that a future release of Cmake handle platform
 naming convention difference internally when invoking ADD_LIBRARY with the IMPORTED tag set?  Ok so, to be fair, Cmake can be used to cross compile and that certainly complicates my feature request but, when not cross compiling, CMake knows what platform it’s
 being executed on so it should be able to resolve static archive platform decorations internally.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas;color:navy">ADD_LIBRARY</span><span style="font-size:8.0pt;font-family:Consolas;color:black">(</span><span style="font-size:8.0pt;font-family:Consolas;color:#345981">test</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><span style="font-size:8.0pt;font-family:Consolas;color:#7f5555">STATIC</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><span style="font-size:8.0pt;font-family:Consolas;color:#007f55">IMPORTED</span><span style="font-size:8.0pt;font-family:Consolas;color:black">)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas;color:black">if(WIN32)</span><span style="font-size:8.0pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:8.0pt;font-family:Consolas;color:navy">   SET_PROPERTY</span><span style="font-size:8.0pt;font-family:Consolas;color:black">(</span><span style="font-size:8.0pt;font-family:Consolas;color:#7f5555">TARGET</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><span style="font-size:8.0pt;font-family:Consolas;color:#345981">test</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><span style="font-size:8.0pt;font-family:Consolas;color:#7f5555">PROPERTY</span><span style="font-size:8.0pt;font-family:Consolas;color:black">
</span><span style="font-size:8.0pt;font-family:Consolas;color:#007f55">IMPORTED_LOCATION</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> ${LIB_D}/timer.lib)</span><span style="font-size:8.0pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">endif()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">if(UNIX)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">   <span style="color:navy">
SET_PROPERTY</span><span style="color:black">(</span><span style="color:#7f5555">TARGET</span><span style="color:black">
</span><span style="color:#345981">test</span><span style="color:black"> </span><span style="color:#7f5555">PROPERTY</span><span style="color:black">
</span><span style="color:#007f55">IMPORTED_LOCATION</span><span style="color:black"> ${LIB_D}/libtimer.a)</span><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">endif()<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks in advance,<u></u><u></u></p>
<p class="MsoNormal" style="margin-top:6.0pt"><b><span style="font-family:"Arial","sans-serif"">Anthony Ette<br>
</span></b><span style="font-family:"Arial","sans-serif"">Control Systems Engineer<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Rolls-Royce Controls and Data Services</span><span style="font-family:"Arial","sans-serif""><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">7661 N Perimeter Rd<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">Indianapolis, IN 46241<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">tel: <a href="tel:%2B1%20%28317%29%20230-6943" value="+13172306943" target="_blank">+1 (317) 230-6943</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">mob: <a href="tel:%2B1%20%28317%29%20864-7975" value="+13178647975" target="_blank">+1 (317) 864-7975</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">email: <a href="mailto:Anthony.R.Ette@controlsdata.com" target="_blank">
Anthony.R.Ette@controlsdata.com</a><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
This e-mail (including attachments) contains contents owned by Rolls-Royce plc and its subsidiaries, affiliated companies or customers and covered by the laws of England and Wales, Brazil, US, or Canada (federal, state or provincial). The information contained
 in this email is intended to be confidential, may be legally privileged and subject to export controls which may restrict the access to and transfer of the information. If you are not the intended recipient, you are hereby notified that any retention, dissemination,
 distribution, interception or copying of this communication is strictly prohibited and may subject you to further legal action. Reply to the sender if you received this email by accident, and then delete the email and any attachments.
</div>

<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>