<div class="gmail_quote">On Mon, Mar 2, 2009 at 7:37 AM, Leopold Palomo Avellaneda <span dir="ltr">&lt;<a href="mailto:leo@alaxarxa.net">leo@alaxarxa.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I have a problem with one project. There&#39;s one file that doesn&#39;t accept a some<br>
compiler flags because g++ then has problems (templates, etc).<br>
<br>
So, I would like to set with another valuer the CMAKE_CXX_FLAGS_RELEASE and<br>
CMAKE_CXX_FLAGS_RELWITHDEBINFO for an _specific_ target.<br>
<br>
I have looked in the documentation and I have found how to add (COMPILE_FLAGS)<br>
but not how to delete/remove flags. Someone hows how to do it?</blockquote><div><br>I&#39;m not sure if CMake has a good way to remove definitions added to CMAKE_CXX_FLAGS or CMAKE_CXX_FLAGS_&lt;FOO&gt;.  I think generally you&#39;re supposed to avoid adding things to this unless you want it to be compiled on all targets.<br>
<br>You can use add_definitions() and remove_definitions() for this
kind of thing provided you don&#39;t need it for a particular release type.<br><br>if(CMAKE_COMPILER_IS_GNUCC)<br>   add_definitions(-Wall)<br>endif()<br>add_subdirectory(foo)<br><br>foo/CMakeLists.txt<br>==========<br>if(CMAKE_COMPILER_IS_GNUCC)<br>

   remove_definitions(-Wall)<br>
endif()<br><br><br>If you do need this for a particular release type you could use STRING(REPLACE...) directly on CMAKE_CXX_FLAGS_RELEASE, for example.<br>Toplevel:<br>=====<br>set(CMAKE_CXX_FLAGS_RELEASE &quot;${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops&quot;)<br>
add_subdirectory(foo)<br>add_subdirectory(bar)<br><br>foo/CMakeLists.txt<br>=====<br>string(REPLACE &quot;-funroll-loops&quot; &quot;&quot; CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})<br>add_executable(bar foo.cc)<br>
<br>Hope that helps<br></div></div><br>-- <br>Philip Lowman<br>