<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.pre
        {mso-style-name:pre;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Use find_library to find the library.  You will probably need this anyway because different systems install libraries in different locations.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><a href="http://www.cmake.org/cmake/help/v3.3/command/find_library.html">http://www.cmake.org/cmake/help/v3.3/command/find_library.html</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> CMake [mailto:cmake-bounces@cmake.org]
<b>On Behalf Of </b>Ette, Anthony (CDS)<br>
<b>Sent:</b> Tuesday, August 18, 2015 1:30 PM<br>
<b>To:</b> CMake@cmake.org<br>
<b>Subject:</b> [CMake] Imported libraries and cross platform target names<br>
<b>Importance:</b> High<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<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 class="pre"><span style="background:#ECF0F3">lib<name>.a</span></span> or<span class="pre"><span style="background:#ECF0F3"><name>.lib”</span></span>), 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….<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></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.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></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">)<o:p></o:p></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"><o:p></o:p></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"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">endif()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">if(UNIX)<o:p></o:p></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><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">endif()<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance,<o:p></o:p></p>
<p class="MsoNormal" style="margin-top:6.0pt"><b><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">Anthony Ette<br>
</span></b><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">Control Systems Engineer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">Rolls-Royce Controls and Data Services<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">7661 N Perimeter Rd<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">Indianapolis, IN 46241<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">tel: +1 (317) 230-6943<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif";mso-fareast-language:EN-GB">mob: +1 (317) 864-7975<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">email: <a href="mailto:Anthony.R.Ette@controlsdata.com">
Anthony.R.Ette@controlsdata.com</a><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman","serif"">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. <o:p></o:p></span></p>
</div>
</body>
</html>