CMake, Eclipse and C++11 together ?
Hi,
The question is simple -- although it drives me crazy: how to have CMake, Eclipse, and C++11 work together?
I've attached a simple program (20 lines of C++ code, and 10 lines of CMakeLists.txt
) for the sake of the demonstration. I build it with these instructions:
cmake -G"Eclipse CDT4 - Unix Makefiles" .
make
=> The program compiles perfectly. However, when importing the generated project into Eclipse, the Code Analysis tool reports several symbol resolution errors:
I've read lots of urban legends... sorry I mean claimed solutions ;-) for this issue on the Internet, among them:
- add
-DCMAKE_CXX_FLAGS="-std=c++11"
on the CMake invocation command, - force the definition of the
__cplusplus
macro to201103L
in Eclipse, - move the
set(CMAKE_CXX_STANDARD 11)
instruction beforeproject(...)
inCMakeLists.txt
...
But none of them works. So what is the solution ?
CMake version is 3.10.1, GCC version is 5.4, and Eclipse version is Oxygen.
Thank you beforehand.