<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 12 (filtered medium)"><style><!--
/* Font Definitions */
@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:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","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-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@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='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I have built clang (llvm) on windows with Visual Studio 2010 and used the built binaries as the compiler inside of a Visual Studio project.&nbsp; This was with clang 3.0 and llvm 2.9.1.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</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-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> cmake-bounces@cmake.org [mailto:cmake-bounces@cmake.org] <b>On Behalf Of </b>Justin Holewinski<br><b>Sent:</b> Thursday, May 24, 2012 1:49 PM<br><b>To:</b> Brad King<br><b>Cc:</b> cmake@cmake.org<br><b>Subject:</b> Re: [CMake] Clang + MinGW Linking Issue<o:p></o:p></span></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On Thu, May 24, 2012 at 10:08 AM, Brad King &lt;<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>&gt; wrote:<o:p></o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>On 05/24/2012 12:22 PM, Justin Holewinski wrote:<br>&gt; I narrowed the problem down to Clang not having Platform/Windows-Clang-{C,CXX}.cmake files.<o:p></o:p></p></div><p class=MsoNormal>There is an issue tracker entry for this:<br><br>&nbsp;<a href="http://www.cmake.org/Bug/view.php?id=13035" target="_blank">http://www.cmake.org/Bug/view.php?id=13035</a><br><br>but it is in the backlog waiting for more feedback and a volunteer.<br>The main problem is distinguishing the GNU-compatible and MS-compatible<br>builds of Clang.<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Oops, missed that issue. &nbsp;Sorry about that!<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>&gt; &nbsp;If I add the following two files then everything starts to work as expected:<br>&gt;<br>&gt; Platform/Windows-Clang-C.cmake:<br>&gt;<br>&gt; if(MINGW)<br>&gt; &nbsp; include(Platform/Windows-GNU)<br>&gt; &nbsp; __windows_compiler_gnu(C)<br>&gt; else()<br>&gt; &nbsp; # Chain to generic Windows configuration<br>&gt; &nbsp; include(Platform/Windows)<br>&gt; endif()<br>&gt;<br>&gt; Platform/Windows-Clang-CXX.cmake:<br>&gt;<br>&gt; if(MINGW)<br>&gt; &nbsp; include(Platform/Windows-GNU)<br>&gt; &nbsp; __windows_compiler_gnu(C)<br>&gt; else()<br>&gt; &nbsp; # Chain to generic Windows configuration<br>&gt; &nbsp; include(Platform/Windows)<br>&gt; endif()<br>&gt;<br>&gt; This way, using Clang with MinGW will force GNU-style platform<br>&gt; options instead of VS-style Windows options.<br>&gt; Is this more or less the &quot;right way&quot; to fix this in CMake?<o:p></o:p></p></div><p class=MsoNormal>Interesting approach. &nbsp;That may be better than separating the<br>compiler id as mentioned in the above-linked issue. &nbsp;The &quot;MINGW&quot;<br>value is set based on CMAKE_C_PLATFORM_ID which is computed in<br>the same way and at the same time as CMAKE_C_COMPILER_ID. &nbsp;Try:<br><br>&nbsp;$ cat Platform/Windows-Clang-C.cmake<br>&nbsp;if(&quot;${CMAKE_C_PLATFORM_ID}&quot; MATCHES &quot;MinGW&quot;)<br>&nbsp; include(Platform/Windows-GNU-C)<br>&nbsp;else()<br>&nbsp; include(Platform/Windows-cl)<br>&nbsp;endif()<br><br>&nbsp;$ cat Platform/Windows-Clang-CXX.cmake<br>&nbsp;if(&quot;${CMAKE_CXX_PLATFORM_ID}&quot; MATCHES &quot;MinGW&quot;)<br>&nbsp; include(Platform/Windows-GNU-CXX)<br>&nbsp;else()<br>&nbsp; include(Platform/Windows-cl)<br>&nbsp;endif()<br><br>Do you have both the MS-style and GNU-style Clang available<br>to test?<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>This works for the MinGW build. &nbsp;I really can't say if this fixes the library naming issue for the MS-style Clang. &nbsp;Clang does not have a VC-compatible driver (that I know of) so does not accept VC-style arguments like &quot;/O2&quot;, which causes CMake to fail early on in the configure process when using the NMake generator. &nbsp;Clang with MinGW is the only really supported configuration at this point.<o:p></o:p></p></div><div><p class=MsoNormal>&nbsp;<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal><br>Thanks,<br>-Brad<o:p></o:p></p></blockquote></div><p class=MsoNormal><br><br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>-- <o:p></o:p></p><div><p class=MsoNormal>Thanks,<o:p></o:p></p></div><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>Justin Holewinski<o:p></o:p></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>