On Tue, Oct 25, 2011 at 8:58 PM, Campbell Barton <span dir="ltr">&lt;<a href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks for that, from reading the docs now this is more clear but for<br>
some reason I had the impression the flags on a file could be<br>
manipulated.<br>
<br>
# ---<br>
# Heres the macro I came up with to disable certain warnings for a<br>
given set of files...<br>
<br>
macro(remove_strict_flags_file<br>
        filenames)<br>
<br>
        foreach(_SOURCE ${ARGV})<br>
<br>
                if(CMAKE_COMPILER_IS_GNUCC)<br>
                        set_source_files_properties(${_SOURCE}<br>
                                PROPERTIES<br>
                                        COMPILE_FLAGS &quot;-Wno-deprecated-declarations&quot;<br>
                        )<br>
                endif()<br>
<br>
                if(MSVC)<br>
                        # TODO<br>
                endif()<br>
<br>
        endforeach()<br>
<br>
        unset(_SOURCE)<br>
<br>
endmacro()<br>
<br>
# ---<br>
# Example use<br>
<br>
remove_strict_flags_file(<br>
        intern/indexer.c<br>
        intern/util.c<br>
        intern/anim_movie.c<br>
)<br>
<div><div></div><div class="h5"><br>
<br>
<br>
On Tue, Oct 25, 2011 at 7:16 PM, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt; On 10/25/2011 09:51 AM, Campbell Barton wrote:<br>
&gt;&gt; The problem I&#39;m trying to solve is to have &quot;-Werror&quot; for the whole<br>
&gt;&gt; project except a few files which include system headers that give<br>
&gt;&gt; warnings we can&#39;t workaround (even with -isystem).<br>
&gt;&gt;<br>
&gt;&gt; So I&#39;m trying to get cmake to replace some flags for a specific file,<br>
&gt;&gt; and I ran into the problem that the variable appears not to be set.<br>
&gt;&gt;<br>
&gt;&gt; get_source_file_property(MYVAR intern/BME_Customdata.c COMPILE_FLAGS)<br>
&gt;&gt; ... modify the MYVAR<br>
&gt;&gt; ... set the flags back<br>
&gt;&gt;<br>
&gt;&gt; But the variable isnt set, Im sure the source file is valid because I<br>
&gt;&gt; printed it from the list passed to the target, and I tried this before<br>
&gt;&gt; and after defining the source file in the target:<br>
&gt;&gt; message(FATAL_ERROR &quot;Check: ${MYVAR}&quot;)<br>
&gt;&gt; Check: NOTFOUND<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m guessing the COMPILE_FLAGS property can be set which overrides the<br>
&gt;&gt; default flags but is there a good way to manipulate the existing<br>
&gt;&gt; flags?<br>
&gt;&gt;<br>
&gt;<br>
&gt; Problem is, that the COMPILE_FLAGS property only *appends* to the<br>
&gt; default compile flags. You&#39;ll have to remove -Werror from<br>
&gt; CMAKE_&lt;LANG&gt;_FLAGS[_&lt;CONFIG&gt;] variables and set it instead on all the<br>
&gt; files you want it to be set for.<br>
&gt;<br>
&gt; Michael<br>
&gt; --<br>
&gt;<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
- Campbell<br>
</font><div><div></div><div class="h5">--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br><div>The flags on a file CAN be manipulated, but Michael&#39;s point was that the flags on a  file are ADDED to the global flags and the flags on its containing target...</div><div><br>
</div><div>So there&#39;s no reliable way to set file flags that will remove flags that were already added by the global or target level flags.</div><div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br></div>