<html 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=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Courier New";
        panose-1:2 7 3 9 2 2 5 2 4 4;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 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:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.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;}
/* List Definitions */
@list l0
        {mso-list-id:298462160;
        mso-list-template-ids:164144346;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:"Courier New";
        mso-bidi-font-family:"Times New Roman";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1338997924;
        mso-list-template-ids:-808542938;}
@list l1:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:"Courier New";
        mso-bidi-font-family:"Times New Roman";}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Hi Andy,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">My build supports several operating systems, including NaCl. The way I solved this problem, essentially, is every place you would normally call target_link_libraries, you replace it with
 a call to LinkPossiblyPrebuiltLibraries, which is a macro I have defined like this:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">macro (LinkPossiblyPrebuiltLibraries artifactName)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">    foreach (nextLibrary ${ARGN})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">        if (NACL AND (CMAKE_GENERATOR MATCHES "Visual Studio.*"))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            # CMake spits out -l<fully-qualified-path>, which throws off clang++ and results in<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            # libraries that can't be found. So instead we explicitly add -l<libname> and<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            # -L${LIBS_DIR}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            set_property (TARGET ${artifactName} APPEND_STRING PROPERTY LINK_FLAGS " -l${nextLibrary}")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            get_target_property (IsImported ${artifactName} "IMPORTED")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">        else ()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">            target_link_libraries (${artifactName} ${nextLibrary})<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">        endif ()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">    endforeach ()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">endmacro ()</span><span style="font-size:11.0pt;font-family:Calibri"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Then separately I add in the link directory:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">if (CMAKE_GENERATOR MATCHES "Visual Studio.*")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">    link_directories ("${LIBS_DIR}/$(Configuration)/${CpuArchSubdir}")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">else ()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">    link_directories ("${NACL_SDK_ROOT}/lib/pnacl/${CMAKE_BUILD_TYPE}")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas">endif ()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">There may very well be some mistakes in there, because I’ve simplified some things that aren’t pertinent to this discussion. I should also point out that I gave up on the Visual Studio
 NaCl toolchain somewhere around the pepper_35 days, because it became apparent that Google wasn’t putting much effort into keeping it a going concern when the equivalent Linux/MacOSX toolchains worked just fine. I guess things have improved since then?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Calibri;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Calibri;color:black"><br>
<b>Parag Chandra<br>
</b>Technical Lead, Mobile Team<br>
Mobile: +1.919.824.1410<br>
<br>
Ionic Security Inc.<br>
1170 Peachtree St. NE STE 400, Atlanta, GA 30309<o:p></o:p></span></p>
<table class="MsoNormalTable" border="0" cellpadding="0" style="background:white">
<tbody>
<tr>
<td nowrap="" style="padding:.75pt .75pt .75pt .75pt"></td>
<td nowrap="" valign="top" style="padding:.75pt .75pt .75pt .75pt"></td>
<td nowrap="" style="padding:.75pt .75pt .75pt .75pt"></td>
<td nowrap="" style="padding:.75pt .75pt .75pt .75pt"></td>
</tr>
<tr>
<td width="5" nowrap="" style="width:3.75pt;padding:.75pt .75pt .75pt .75pt"></td>
<td width="70" nowrap="" valign="top" style="width:52.5pt;padding:.75pt .75pt .75pt .75pt">
</td>
<td width="5" nowrap="" style="width:3.75pt;padding:.75pt .75pt .75pt .75pt"></td>
<td width="287" nowrap="" valign="top" style="width:215.25pt;padding:.75pt .75pt .75pt .75pt">
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">CMake <cmake-bounces@cmake.org> on behalf of Andy Yelland <ay@numfum.com><br>
<b>Date: </b>Tuesday, October 18, 2016 at 1:56 PM<br>
<b>To: </b>"cmake@cmake.org" <cmake@cmake.org><br>
<b>Subject: </b>[EXTERNAL]: [CMake] Visual Studio generator, cross-compiling<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Hi there<br>
<br>
I am trying to coax a Cmake generation of a Visual Studio project of our cross-platform product, that includes the PNaCl platform.  The MSBuild setup for PNaCl is a little bit fussy, and does not like the relative pathnames in <AdditionalDependencies>, that
 get produced when the product has target_link_libraries setup between the static libraries in the product.  For the sake of this mail I'll call the library project 'LibProject', which as it's based on unix toolchain, will get the static lib created as libLibProject.a. 
 To be used as a command-line on the PNaCl cross-compiler, then it needs to get translated to -lLibProject  (without the lib prefix, or the .a suffix).<br>
<br>
So going into the Visual Studio generator for the EXE project, at present are the relative paths (will use Debug for this example):  ../LibProject/Debug/libLibProject.a  which gets added to the <AdditionalDependencies> tag in the .vcxproj<br>
<br>
To make the PNaCl MSBuild extension work, then instead it needs to be:<o:p></o:p></p>
<ul type="disc">
<li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo1">
<AdditionalDependencies>LibProject</AdditionalDependencies> <o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l1 level1 lfo1">
<AdditionalLibraryDirectories>../LibProject/Debug</AdditionalLibraryDirectories> <o:p>
</o:p></li></ul>
<p>I am well aware that these get set by the cmake functions: target_link_libraries() and link_directories(), so feel this ought to be possible by Cmake script.<o:p></o:p></p>
<p>What I'm struggling with, is finding *a place* where I can:<o:p></o:p></p>
<ul type="disc">
<li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo2">
Query all the libraries that have become dependent on a target (the input to the Generator).  As target_link_libraries cascade, so my EXE project does not know about all of its leaf libraries, so I'm not really sure if there is a target property with ALL the
 dependent static library projects)<o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo2">
Adjust this list, stripping: path, 'lib' and '.a' <o:p></o:p></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo2">
Inserting link_directories (or the equivalent, presuming it's some target property now), corresponding to the relative paths that were stripped in the step above
<o:p></o:p></li></ul>
<p>All of this would need to happen, after we've finished setting up the target, but before the generator.  Ideally this would be something I defined in the ToolChain folder - but I can't think of any kind of callback in the CMake system.<o:p></o:p></p>
<p>I'm open to other suggestions, about how to setup this visual studio cross-compile.  While PNaCl + MSDev may be rare, I feel that cross-compiling for other unix systems with -l and -L library and path command-lines ought to have been done before with Visual
 Studio generators.<o:p></o:p></p>
<p>Thanks in advance<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>Andy<o:p></o:p></p>
</div>
</body>
</html>