Set __cplusplus value for C++11, EclipseCDT4
CMake version: 3.5.1
Eclipse version: Neon.3 Release (4.6.3), Build id: 20170314-1500
When creating a project with
set_target_properties(TargetName PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
and generating the project files with the generator "Eclipse CDT4 - Unix Makefiles":
After opening the project with Eclipse, the source code is not treated as C++11 by the IDE.
Compiling works perfectly, but the built-in auto-complete and source parser show all C++11 features as errors because the symbol __cplusplus is set to 199711L per default.
Changing the symbol after creating the project fixes this issue.
Is it possible to already set the __cplusplus symbol to 201103L when generating with the C++11 standard set (and maybe other standards to their respective values)?
EDIT:
Given the test project
Create a folder on the same level as the project folder:
|-Test
|-Test-build
Inside of Test-build execute
cmake -G"Eclipse CDT4 - Unix Makefiles" ./../Test/
Open up the Eclipse IDE (C++) and import the project folder (Test-build)into the workspace:
- File -> Import...
- General -> Existing Projects into Workspace
- Click Next -> Select root directory -> Browse and select the "Test-build" folder
The resulting screen:
The code assistant fails to parse C++11 dependent features but even though the IDE shows errors, at this point compiling the project already works.
The IDE shows these errors because the following is set:
- Left click on the project name -> Properties
- C/C++ Include Paths and Symbols -> the symbol __cplusplus is set to "199711L"
To fix this issue, the value has to be manually set to "201103L"
Now the Index needs to be rebuild/the project needs to be reparsed:
- Project -> C/C++ Index -> Rebuild
Which results in the IDE being able to parse/provide support for C++11 features
The expected outcome would be that an Eclipse project generated this way would have this setting already without the need to manually change the IDE symbol.