[CMake] Generate Eclipse project with support for c++ 11

Luca Gherardi luca.gherardi at unibg.it
Fri Dec 5 03:58:17 EST 2014


Hi all,

I’m writing a CMake file for a project that should be compiled both in Ubuntu and OS X.
I want to use eclipse as IDE, gcc and C++ 11.

I read different threads that suggest how to enable C++ 11 in eclipse.
According to them I included these lines in my CMake:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

if (${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4")
	set(CMAKE_CXX_COMPILER_ARG1 "-std=c++11" CACHE STRING "C++ version for eclipse" FORCE)
	set(CMAKE_ECLIPSE_VERSION "4.3" CACHE STRING "Eclipse version" FORCE)
endif (${CMAKE_EXTRA_GENERATOR} MATCHES "Eclipse CDT4”)

However, eclipse still set a wrong value for the symbol __cplusplus (199711L instead of 201103L I guess).
For this reason eclipse is not able to index C++ 11 features such as shared pointer.
Therefore I get a syntax error also if the code compiles.

Any idea on how can I address this issue?

Thanks,
Luca




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141205/ef619c11/attachment.html>


More information about the CMake mailing list