title: Creating Xcode project from Cmake contains unwanted compiler flags
body: <p>I've been unable to find a definitive answer, so apologies if the answer is out there.</p>
  
  <p>I use cmake to generate project files as I tend to work cross-platform. On OSX/Xcode, I'm seeing unwanted compiler flags being used, specifically warning enable/disable. I like to compile with as many warnings on as possible, and set warnings as errors.</p>
  
  <p>Consider the following:</p>
  
  <p>File: <em>CMakeLists.txt</em></p>
  
  <pre><code>cmake_minimum_required( VERSION 3.0 )
  project( test )
  set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++14 )
  add_compile_options( "-Werror" )
  add_compile_options( "-Weverything" )
  add_compile_options( "-Wno-c++98-compat-pedantic" )
  add_compile_options( "-Wno-padded" )
  add_executable( Test main.cpp )
  target_link_libraries( Test libstdc++.dylib libc++.dylib )
  </code></pre>
  
  <p>File: <em>main.cpp</em></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main( int argc, char * const argv[] )
  {
      (void)argc;
      (void)argv;
      std::cout &lt;&lt; "Kittens." &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>If I then run cmake:</p>
  
  <pre><code>cmake -G Xcode .
  </code></pre>
  
  <p>(normally I'd use a builds directory, but not here for simplicity).</p>
  
  <p>Then build (from the command line):</p>
  
  <pre><code>cmake --build . --config Debug --target ALL_BUILD
  </code></pre>
  
  <p>The simple sample will compile. If I now look at the command used to compile main.cpp I see the following:</p>
  
  <pre><code>CompileC test.build/Debug/Test.build/Objects-normal/x86_64/main.o main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
      cd /Users/username/Development/test
      export LANG=en_US.US-ASCII
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=101 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE_INTDIR=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.11 -g -Wno-sign-conversion -I/Users/username/Development/test/Debug/include -I/Users/username/Development/test/test.build/Debug/Test.build/DerivedSources/x86_64 -I/Users/username/Development/test/test.build/Debug/Test.build/DerivedSources -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -F/Users/username/Development/test/Debug -std=c++14 -Werror -Weverything -Wno-c++98-compat-pedantic -Wno-padded -MMD -MT dependencies -MF /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.dia -c /Users/username/Development/test/main.cpp -o /Users/username/Development/test/test.build/Debug/Test.build/Objects-normal/x86_64/main.o
  </code></pre>
  
  <p>The really annoying thing here is any of the -W options.
  In my CMakeLists.txt I've clearly said I want all warnings, warnings treated as errors, and whitelisted a couple of warnings.</p>
  
  <p>However, if I strip out all the -W options in the compile command, I see (in addition to what I asked for):</p>
  
  <pre><code>-Wno-trigraphs
  -Wno-missing-field-initializers
  -Wno-missing-prototypes
  -Wno-return-type
  -Wno-non-virtual-dtor
  -Wno-overloaded-virtual
  -Wno-exit-time-destructors
  -Wno-missing-braces
  -Wparentheses
  -Wswitch
  -Wno-unused-function
  -Wno-unused-label
  -Wno-unused-parameter
  -Wno-unused-variable
  -Wunused-value
  -Wno-empty-body
  -Wno-uninitialized
  -Wno-unknown-pragmas
  -Wno-shadow
  -Wno-four-char-constants
  -Wno-conversion
  -Wno-constant-conversion
  -Wno-int-conversion
  -Wno-bool-conversion
  -Wno-enum-conversion
  -Wno-shorten-64-to-32
  -Wno-newline-eof
  -Wno-c++11-extensions
  -Winvalid-offsetof
  -Wno-sign-conversion
  -Wmost
  -Wno-four-char-constants
  -Wno-unknown-pragmas
  </code></pre>
  
  <p>Some of those things listed I really do not want disabled. I really want just the -W options I specified in the cmake file being used for compilation, but I can't see who is injecting all these extra things and from where.</p>
  
  <p>Is there any way I can get cmake to tell xcode not to include all these extra -W options from compilation?</p>
  
  <p>Note: using:</p>
  
  <p>cmake 3.5.2</p>
  
  <p>Apple LLVM version 7.3.0 (clang-703.0.31)</p>