I do something like this in one CMakeLists file and it works for me:<br><br>IF(MSVC)<br> # force treat warnings as errors: /WX<br> # force warning level 4<br> #<br> FOREACH(lang C CXX)<br>
IF("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")<br> STRING(REGEX REPLACE "/W[1-3]" "/W4 /WX" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}")<br> MESSAGE(STATUS "Replacing /W[1-3] with /W4 /WX...")
<br> ELSE("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")<br> SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} /W4 /WX")<br> MESSAGE(STATUS "Adding /W4 /WX...")<br> ENDIF("${CMAKE_${lang}_FLAGS}" MATCHES "/W[1-3]")
<br> ENDFOREACH(lang)<br>ENDIF(MSVC)<br>
<br>In the IF clause, I use "STRING(REGEX REPLACE" to do an in-place replacement of, for example, "/W3" with "/W4 /WX".<br><br>In the ELSE clause, I simply use "SET" 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> <<a href="mailto:jesse.corrington@gmail.com">jesse.corrington@gmail.com</a>> 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 <
<a href="mailto:david.cole@kitware.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.cole@kitware.com</a>> 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 "/subsystem") why don't you just add "WIN32" 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> <<a href="mailto:jesse.corrington@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jesse.corrington@gmail.com</a>> 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 "windows" for a vc 2005 build, but I don'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>