From cmake Mon May 18 15:09:15 2015 From: Andreas Pakulat Date: Mon, 18 May 2015 15:09:15 +0000 To: cmake Subject: Re: [CMake] Where do all the extra clang flags come from in Xcode? Message-Id: X-MARC-Message: https://marc.info/?l=cmake&m=143196176414239 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1090992986==" --===============1090992986== Content-Type: multipart/alternative; boundary=001a11473b24c7089a05165c93b9 --001a11473b24c7089a05165c93b9 Content-Type: text/plain; charset=UTF-8 Hi Paul, On Mon, May 18, 2015 at 3:20 PM, Paul Smith 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? > > 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 --001a11473b24c7089a05165c93b9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Paul,

On Mon, May 18, 2015 at 3:20 PM, Paul Smith <<= a href=3D"mailto:paul@mad-scientist.net" target=3D"_blank">paul@mad-scienti= st.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<= br> > specific warning.

I see, so these are CMake attributes?=C2=A0 That wasn't clear to= me.=C2=A0 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?=C2=A0 I expected it=
would work like the makefile generator, where if you don't set any flag= s
in CMakeLists.txt then you don't get any warnings enabled (or explicitl= y
disabled).=C2=A0 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 sty= le) you'll notice just 1 file and there are not a lot of -W words insid= e that file either. I see 3 warnings being added by CMake when generating t= his file.

That suggests anything else is added by = Xcode itself because thats what its default settings are. Xcode (and xcodeb= uild) has a lot more logics builtin that make. Make is essentially just a d= ependency-tracking and execution tool and thus cannot make any assumptions = about what is being executed when a target is to be 'made'. It cann= ot add any compile flags that the make-developers deem useful, since the ac= tion executed for a target may not be a compile run at all. Xcode on the ot= her hand with its more structured project file has a very clear idea of wha= t 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 c= ompiler invocations.

You'll also notice this w= hen 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 =C2=A0literally = none, but still xcodebuild shows tons of -W flags added to the compiler inv= ocation.
=C2=A0
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?

Given the above, your only options are: propose = a patch to cmake (or find someone to do this for you) that enhances the xco= de generator to disable all flags that are not explicitly enabled so its cl= oser to the makefile generator. This is however quite a lot of effort upfro= nt and in maintenance since each new xcode version (even just bugfix versio= ns) 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
--001a11473b24c7089a05165c93b9-- --===============1090992986== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- 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 --===============1090992986==--