[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Where do all the extra clang flags come from in Xcode?
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2015-05-18 15:09:15
Message-ID: CAExHGmSQ7ufAd5DtyAw9oE4Zs97nECyQC_P9MS+qJVpFXL43Dg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Paul,

On Mon, May 18, 2015 at 3:20 PM, Paul Smith <paul@mad-scientist.net> wrote:

> On Mon, 2015-05-18 at 12:32 +0200, Ruslan Baratov via CMake wrote:
> > This table tells you what attribute you need to set to disable/enable
> > specific warning.
>
> I see, so these are CMake attributes?  That wasn't clear to me.  I
> thought they were attributes of Xcode.
>
> I guess my basic question is, why are all these extra flags to disable
> and enable various warnings set in the Xcode generator?  I expected it
> would work like the makefile generator, where if you don't set any flags
> in CMakeLists.txt then you don't get any warnings enabled (or explicitly
> disabled).  It surprises me that when I take the same CMakeLists.txt
> file and use a Makefile generator and an Xcode generator, I get very
> different compile lines.
>

If you look at the foo.xcodeproj contents of a very simple CMake project
(hello-world style) you'll notice just 1 file and there are not a lot of -W
words inside that file either. I see 3 warnings being added by CMake when
generating this file.

That suggests anything else is added by Xcode itself because thats what its
default settings are. Xcode (and xcodebuild) has a lot more logics builtin
that make. Make is essentially just a dependency-tracking and execution
tool and thus cannot make any assumptions about what is being executed when
a target is to be 'made'. It cannot add any compile flags that the
make-developers deem useful, since the action executed for a target may not
be a compile run at all. Xcode on the other hand with its more structured
project file has a very clear idea of what is a compile action and what is
not and apparently the Apple devs think a certain set of flags are useful
for everybody and hence are added to all compiler invocations.

You'll also notice this when creating a new project inside xcode and then
examine and run it outside, i.e. grep for -W flags in the generated files.
There are  literally none, but still xcodebuild shows tons of -W flags
added to the compiler invocation.


> And secondarily, is there any way to get the Xcode generator to work
> like the Makefile generator, where only the warning flags I explicitly
> defined in my CMakeLists.txt file are added to the compile/link lines
> and no others?
> <http://cmake.org/cmake/help/consulting.html>
>

Given the above, your only options are: propose a patch to cmake (or find
someone to do this for you) that enhances the xcode generator to disable
all flags that are not explicitly enabled so its closer to the makefile
generator. This is however quite a lot of effort upfront and in maintenance
since each new xcode version (even just bugfix versions) may need changes
to the list.

The alternative to that is that you blacklist via the mentioned attributes
the warnings you don't want to have enabled, each and every one of them
individually.

Andreas

[Attachment #5 (text/html)]

<div dir="ltr">Hi Paul,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, \
May 18, 2015 at 3:20 PM, Paul Smith <span dir="ltr">&lt;<a \
href="mailto:paul@mad-scientist.net" \
target="_blank">paul@mad-scientist.net</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span class="">On Mon, 2015-05-18 at 12:32 +0200, Ruslan \
Baratov via CMake wrote:<br> &gt; This table tells you what attribute you need to set \
to disable/enable<br> &gt; specific warning.<br>
<br>
</span>I see, so these are CMake attributes?   That wasn&#39;t clear to me.   I<br>
thought they were attributes of Xcode.<br>
<br>
I guess my basic question is, why are all these extra flags to disable<br>
and enable various warnings set in the Xcode generator?   I expected it<br>
would work like the makefile generator, where if you don&#39;t set any flags<br>
in CMakeLists.txt then you don&#39;t get any warnings enabled (or explicitly<br>
disabled).   It surprises me that when I take the same CMakeLists.txt<br>
file and use a Makefile generator and an Xcode generator, I get very<br>
different compile lines.<br></blockquote><div><br></div><div>If you look at the \
foo.xcodeproj contents of a very simple CMake project (hello-world style) you&#39;ll \
notice just 1 file and there are not a lot of -W words inside that file either. I see \
3 warnings being added by CMake when generating this \
file.</div><div><br></div><div>That suggests anything else is added by Xcode itself \
because thats what its default settings are. Xcode (and xcodebuild) has a lot more \
logics builtin that make. Make is essentially just a dependency-tracking and \
execution tool and thus cannot make any assumptions about what is being executed when \
a target is to be &#39;made&#39;. It cannot add any compile flags that the \
make-developers deem useful, since the action executed for a target may not be a \
compile run at all. Xcode on the other hand with its more structured project file has \
a very clear idea of what is a compile action and what is not and apparently the \
Apple devs think a certain set of flags are useful for everybody and hence are added \
to all compiler invocations.</div><div><br></div><div>You&#39;ll also notice this \
when creating a new project inside xcode and then examine and run it outside, i.e. \
grep for -W flags in the generated files. There are   literally none, but still \
xcodebuild shows tons of -W flags added to the compiler invocation.</div><div>  \
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> And secondarily, is there any way to get the Xcode generator \
to work<br> like the Makefile generator, where only the warning flags I \
explicitly<br> defined in my CMakeLists.txt file are added to the compile/link \
lines<br> and no others?<div class="HOEnZb"><div class="h5"><a \
href="http://cmake.org/cmake/help/consulting.html" \
target="_blank"></a></div></div></blockquote><div><br></div><div>Given the above, \
your only options are: propose a patch to cmake (or find someone to do this for you) \
that enhances the xcode generator to disable all flags that are not explicitly \
enabled so its closer to the makefile generator. This is however quite a lot of \
effort upfront and in maintenance since each new xcode version (even just bugfix \
versions) may need changes to the list.</div><div><br></div><div>The alternative to \
that is that you blacklist via the mentioned attributes the warnings you don&#39;t \
want to have enabled, each and every one of them \
individually.</div><div><br></div><div>Andreas</div></div></div></div>



-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic