title: How to detect C++11 support of a compiler with CMake
body: <p>Is there a way to let CMake detect automatically if a compiler supports C++11 or not?</p>
  
  <p>As it would be nice to inform the users during the CMake run that the code will not compile as the compiler does not support C++11. At the moment I set the C++11 flags. However, if a compiler does not support it the user gets compile errors instead of an error during the CMake run.</p>
  
  <p>Perfect would be something that works like <code>find_package()</code>. However, I have not found any module or function which provides the functionality needed.</p>
  
  <p>Additional it would be nice to have the feature to detect if the compiler needs the flags <code>std=c++0x</code> or <code>std=c++11</code>.</p>
  
  <p>Is there something available or do I need to develop this on my own?</p>
  
  <p>Below is some code I use so far, however it works only with GNU'c GCC compilers. It would be nice if there would be a more general solution.</p>
  
  <pre><code>if(CMAKE_COMPILER_IS_GNUCXX)
     execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
     if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
          message(STATUS "C++11 activated.")
          add_definitions("-std=gnu++11")
     elseif(GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3)
          message(WARNING "C++0x activated. If you get any errors update to a compiler which fully supports C++11")
          add_definitions("-std=gnu++0x")
     else ()
          message(FATAL_ERROR "C++11 needed. Therefore a gcc compiler with a version higher than 4.3 is needed.")   
     endif()
  else(CMAKE_COMPILER_IS_GNUCXX)
     add_definitions("-std=c++0x") 
  endif(CMAKE_COMPILER_IS_GNUCXX)
  </code></pre>