<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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.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">“trying to use CMake the wrong way, and that's why it gets in your way"<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yes that could very likely be the case.  I want to add compile flags to build with target-specific tuning options in order to build different versions of libcxx.  The driver picks the right version of the library given the corresponding
 link arguments.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It seems like if there were an empty-by-default-but-overridable-in-cache “LIBCXX_EXTRA_CFLAGS” (and LIBCXXABI_/LIBUNWIND_) it would be an effective way to get what I’m looking for.  But as you point out it might not be the Right Way.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-Brian<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Louis Dionne <ldionne@apple.com> <br>
<b>Sent:</b> Tuesday, September 1, 2020 12:39 PM<br>
<b>To:</b> Brian Cain <bcain@quicinc.com><br>
<b>Cc:</b> libcxx-dev@lists.llvm.org<br>
<b>Subject:</b> [EXT] Re: [libcxx-dev] cmake caches w/additional compile+link flags<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Aug 18, 2020, at 11:10, Brian Cain via libcxx-dev <<a href="mailto:libcxx-dev@lists.llvm.org">libcxx-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">In an internal project, we build libcxx+libcxxabi with many settings configured in a cmake cache file.  It gets invoked roughly like so:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:.5in"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:.5in">cmake -DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi;pstl -C./libcxx/xyz/target.cmake -DCMAKE_INSTALL_PREFIX=/target/install/path ../llvm-project/llvm<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">… I would prefer to include as many of the relevant build settings as possible in the ‘target.cmake’ file.  Today we clobber “CMAKE_CXX_FLAGS” with the required target-specific flags in that file and it’s effective.  But it doesn’t cooperate
 well with the rest of the libcxx/libcxxabi cmake configuration. <span class="apple-converted-space"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">This seems really simple but I’ve never quite been able to figure out how to append flags to the build configuration from the cmake cache.  I’ve tried a few different ways of writing to LIBCXX_COMPILE_FLAGS (including with CACHE FORCE)
 but even if the value in LIBCXX_COMPILE_FLAGS persists in the CMakeCache.txt they don’t seem to be reflected in the flags used to build.  So it’s probably some cmake rules I don’t quite understand about the order or scope in which LIBCXX_COMPILE_FLAGS is defined. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I’m sure I’m missing something simple – can anyone share a good way to accomplish my goal of adding/removing compile+link flags in the preloaded cmake cache file?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm not sure there's a way to do that -- the question I'd have is what flags are you trying to set? At first sight, it looks to me like you're trying to use CMake the wrong way, and that's why it gets in your way :-). There might be another
 way of achieving what you're trying to do.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Louis<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>