title: CMake and compiler warnings
body: <p>I use <code>CMake</code> to generate unix makefiles. After that I compile project using <code>make</code> utility.
  Problem is that I can't see any warnings! For example, this results in clean build without warnings:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Foo
  {
      int first;
      int second;
  public:
      Foo(int a, int b)
      : second(a) // invalid initialization order
      , first(b)
      {
      }
  };
  
  int main(int argc, char** argv)
  {
      int unused; // unused variable
      int x;
      double y = 3.14159;
      x = y; // invalid cast
      Foo foo(1,2);
      std::cout &lt;&lt; y &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>Unused variable and lossy variable cast - no warnings! My <code>CMakeLists.txt</code> file is minimalistic:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  
  add_executable(main main.cpp)
  </code></pre>
  
  <p>When I run <code>cmake</code> and then <code>make</code> my output looks like this:</p>
  
  <pre><code>[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
  Linking CXX executable main
  [100%] Built target main
  </code></pre>
  
  <p>But when I add this line of code:</p>
  
  <pre><code>#warning ("Custom warning")
  </code></pre>
  
  <p>resulting output contains warning:</p>
  
  <pre><code>[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
  ../src/main.cpp:15:2: warning: #warning ("Custom Warning") [-Wcpp]
  Linking CXX executable main
  [100%] Built target main
  </code></pre>
  
  <p>I use Ubuntu 12.04 LTS and GCC as a compiler. Maybe CMake passes some flag to compiler that results in absence of warnings. How can I check it? I can't read makefiles generated by CMake, they are a little bit cryptic.</p>