Using CMake you usually enable C++11 using a compiler flag like:

set(CMAKE_CXX_FLAGS "-std=c++11")

This works well but seems not to be compatible with the Eclipse CDT4 Plugin. All include paths and predefined macros will be set to C++-03, thus Eclipse will miss new features like std::shared_ptr.

The problem is, that the Eclipse Include Paths and predefined Macros are set by a compiler call directly. This happens inside /usr/local/share/cmake-2.8/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake.

execute_process(COMMAND ${_compilerExecutable} ${_arg1} -v -E -x ${_lang} -dD dummy
  OUTPUT_VARIABLE _gccStdout )

How can this be avoided? The simplest solution (as long as C++11 is not the default) seems to either patch CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake or wrap the compiler inside a Shellscript:

# Place this in $HOME/bin/g++11 and make it executable
/usr/bin/g++ -std=c++11 "$@"

Now you can rerun CMake with the new "Compiler" and voila, Eclipse recognizes the new C++11 types.

cmake ../your_source_dir -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_COMPILER=g++11