<br><br><div class="gmail_quote">On Thu, Aug 23, 2012 at 11:14 AM, Jason T. Slack-Moehrle <span dir="ltr">&lt;<a href="mailto:slackmoehrle@gmail.com" target="_blank">slackmoehrle@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">&gt;&gt; I am trying to use come C++v11 features and am trying to get the<br>
&gt;&gt; compiling to work.<br>
<br>
</div><div class="im">&gt;&gt; SET( CMAKE_CXX_FLAGS &quot;-std=c++11 -stdlib=libc++&quot; )<br>
&gt;&gt;<br>
&gt;&gt; PROJECT( ${PROJECT_NAME} )<br>
&gt;<br>
&gt; PROJECT will set up the compiler and stuff. And in this process it will set<br>
&gt; CMAKE_CXX_FLAGS, i.e. will overwrite your lines. Exchange the lines and make<br>
&gt; sure not to overwrite the existing flags, but append to them.<br>
<br>
</div>This worked.<br>
<br>
Can you explain how I would/should have known that PROJECT will<br>
specify compiler and stuff when I am passing it in with the cmake<br>
command as well as using the SET statement above?<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div><br></div><div>Unfortunately, it&#39;s just one of those things that &quot;everybody knows&quot; -- at least those who have stuck with it through the hard-knocks school of CMake learning...</div>
<div><br></div><div>What did you read and where did you look before you got to this point?</div><div><br></div><div>If you can answer that, then I can say where we should put the following documentation:</div><div><br></div>
<div>In one of those places, we should state, uncategorically:</div><div><br></div><div>The first two lines of any CMakeLists.txt file should be:</div><div>cmake_minimum_required</div><div>project</div><div><br></div><div>
Only people who know how it all works should do anything other than that.</div><div><br></div><div>We should also state on one of those places that the project command sets up a lot of stuff for you internally, including compiler selection, and that the &quot;right&quot; way to override that is by environment variables CC and CXX before the initial call to CMake.</div>
<div><br></div><div>And that the right way to adjust flags is to append them to CMAKE_CXX_FLAGS *after* the project command.</div><div><br></div><div>In the end, you found your way to the CMake mailing list, and we try to be fairly useful in our responses here. Hope you found it reasonable despite the frustrations in getting there.</div>
<div><br></div><div><br></div><div>Cheers,</div><div>David</div><div><br></div></div>