I do something like this in one CMakeLists file and it works for me:<br><br>IF(MSVC)<br>&nbsp; #&nbsp;&nbsp;&nbsp; force treat warnings as errors: /WX<br>&nbsp; #&nbsp;&nbsp;&nbsp; force warning level 4<br>&nbsp; #<br>&nbsp; FOREACH(lang C CXX)<br>
&nbsp; &nbsp; IF(&quot;${CMAKE_${lang}_FLAGS}&quot; MATCHES &quot;/W[1-3]&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STRING(REGEX REPLACE &quot;/W[1-3]&quot; &quot;/W4 /WX&quot; CMAKE_${lang}_FLAGS &quot;${CMAKE_${lang}_FLAGS}&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MESSAGE(STATUS &quot;Replacing /W[1-3] with /W4 /WX...&quot;)
<br>&nbsp;&nbsp;&nbsp; ELSE(&quot;${CMAKE_${lang}_FLAGS}&quot; MATCHES &quot;/W[1-3]&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SET(CMAKE_${lang}_FLAGS &quot;${CMAKE_${lang}_FLAGS} /W4 /WX&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MESSAGE(STATUS &quot;Adding /W4 /WX...&quot;)<br>&nbsp;&nbsp;&nbsp; ENDIF(&quot;${CMAKE_${lang}_FLAGS}&quot; MATCHES &quot;/W[1-3]&quot;)
<br>&nbsp; ENDFOREACH(lang)<br>ENDIF(MSVC)<br>
<br>In the IF clause, I use &quot;STRING(REGEX REPLACE&quot; to do an in-place replacement of, for example, &quot;/W3&quot; with &quot;/W4 /WX&quot;.<br><br>In the ELSE clause, I simply use &quot;SET&quot; to append the extra flags.
<br><br><br>HTH,<br>David<br><br><br><div><span class="gmail_quote">On 11/28/07, <b class="gmail_sendername">Jesse Corrington</b> &lt;<a href="mailto:jesse.corrington@gmail.com">jesse.corrington@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks, that works for this specific example. As far as setting other flags, is my best bet just to do what I was thinking of removing the flag and re-adding it?
<div><span class="e" id="q_11688950409e522a_1"><br><br><div class="gmail_quote">On Nov 28, 2007 2:35 PM, David Cole &lt;
<a href="mailto:david.cole@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.cole@kitware.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Instead of trying it the hard way (specifically for &quot;/subsystem&quot;) why don&#39;t you just add &quot;WIN32&quot; to your ADD_EXECUTABLE call?
<br><br>CMake will automatically create a console app for ADD_EXECUTABLE with no flags, and a windows app for ADD_EXECUTABLE with the WIN32 flag...
<br><br>Or were you asking because there is a different use for /subsystem, rather than simply adding WIN32 to your ADD_EXECUTABLE call...?<br><br><br>HTH,<br>David<br><br><div><div><div></div><div><span class="gmail_quote">

On 11/28/07, <b class="gmail_sendername">
Jesse Corrington</b> &lt;<a href="mailto:jesse.corrington@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jesse.corrington@gmail.com</a>&gt; wrote:</span></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div>
I want to set the flag /subsystem to &quot;windows&quot; for a vc 2005 build, but I don&#39;t want to clear out all the flags and set it. The best way I can think of to do this is to iterate over the default flags until I get to /subsystem and remove it and its value, and then add the flag with the value I want. I just want to make sure this is the best way to handle this. Any thoughts?
<br><br>Thanks<br><span><br>Jesse<br>
</span><br></div></div>_______________________________________________<br>CMake mailing list<br><a href="mailto:CMake@cmake.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br>
</blockquote></div><br>
</span></div></blockquote></div><br>