[CMake] Where do all the extra clang flags come from in Xcode?

Paul Smith paul at mad-scientist.net
Thu May 14 17:53:22 EDT 2015


I was comparing the command line used when we choose an Xcode generator
on our OSX systems, vs. the command line used when we choose a Makefile
generator.  We certainly have nothing in our CMakeLists.txt which sets
compiler flags based on the type of generator, only based on the type of
compiler (GCC, Clang, etc.)

But, when I look at the compiler and flags used by the Makefile
generator it uses /usr/bin/c++ (which is clang++ underneath) and it's
basically only the the compiler flags that we provided.

When I look at the compiler and flags used by the Xcode generator, not
only does it use a different path to the compiler
(/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++) but, more concerning (because I assume that /usr/bin/clang++ eventually gets down to the same actual compiler as above) but it contains a huge number of extra flags, for example it appears to disable all sorts of warnings (that we don't want disabled):  -Wno-missing-prototypes, -Wno-return-type, -Wno-non-virtual-dtor, -Wno-overloaded-virtual, etc. etc.

This means people who build on OSX using Makefile generators see extra
warnings that people who build on OSX using Xcode don't see.

Where are these extra flags all coming from?  Is it from Xcode itself
somehow?  Can I keep them from being added?  I don't want peoples'
personal Xcode settings to disable warnings during compilation!

Note these are build servers and so no one is actually invoking Xcode:
we log in via SSH, use cmake to generate the Xcode project files, then
use cmake -build (which runs xcodebuild) to run the build itself.



More information about the CMake mailing list