<div dir="ltr">On Wed, Jun 26, 2013 at 9:38 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Wed, Jun 26, 2013 at 5:48 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
> On Wed, Jun 26, 2013 at 8:22 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
> What I have in mind right now is CMake, where every user pretty much does<br>
> their own ad hoc flag checking and munging. Every CMake user would have to<br>
> say add_cflag_if_supported("-fblah") / add_cflag_if_supported("-Xescape<br>
> -fblah"), or it would be in some 'if clang' block.<br>
<br>
</div></div>It needs to be in an "if clang" block regardless if these are<br>
clang-specific flags. And they need the -Xwhatever regardless if the<br>
flag means something else to cl.exe. Also, I don't see any problem<br>
with supporting -Xwhatever from both drivers, so you don't even need<br>
special case code for the cl.exe case. Just do:<br>
<br>
if(clang)<br>
add_cflag_if_supported("-Xwhatever -fblah")<br>
endif(clang)</blockquote><div><br></div><div>I don't think that's standard practice for existing CMake and autoconf build systems. I've met many people who believe in feature testing compiler flags with a test compile, rather than maintaining a list of compiler vendors and versions that support a given flag. Personally, I've always hated this because it's really expensive and wastes a lot of time.</div>
<div><br></div><div>The other school of thought is to do the obvious thing and say "if gcc, add -fno-rtti, if msvc, add /GR-", and then change it when you need to build with clang.</div><div><br></div><div>I also don't want to ask people to escape gcc style flags everywhere. Consider -Wextra, which gcc and clang accept, and today might be written as 'add_if_supported(-Wextra)' or 'if (gcc_compatible) add(-Wextra)'.</div>
<div><br></div><div>It seems best to have that work for all of gcc, clang, and clang-cl, without adding code to add on -Xescape for clang.</div></div></div></div>