View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015316 | CMake | CMake | public | 2014-12-18 08:46 | 2016-06-10 14:31 | ||||
Reporter | lucaghera | ||||||||
Assigned To | Kitware Robot | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | Apple Mac | OS | OS X | OS Version | 10.4.10 | ||||
Product Version | CMake 3.0.2 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015316: Generation of Eclipse project does not provide support for c++ 11 | ||||||||
Description | 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). In the generated file .cproject this should be the line <pathentry kind="mac" name="__cplusplus" path="" value="199711L"/> (in my case 265) 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. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0037479) Brad King (manager) 2014-12-18 09:04 |
I think this was fixed in 'master' recently by these commits: Code Blocks/Eclipse: Use non-default stdlib includes when specified. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45a25d63 [^] Code Blocks/Eclipse: Add -std= flag matching. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eaf6f67f [^] Please build from source or try a nightly binary: http://www.cmake.org/files/dev/?C=M;O=D [^] |
(0037480) lucaghera (reporter) 2014-12-18 09:17 |
I just tried to download the version cmake-3.1.20141217-g9a64b on both Mac and Ubuntu. The generated .cproject is still incorrect. The variable __cplusplus is still set to 199711L <pathentry kind="mac" name="__cplusplus" path="" value="199711L"/> |
(0037481) Brad King (manager) 2014-12-18 09:27 |
Try hacking on Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake get it to extract the __cplusplus builtin definition from its trial run of the compiler. |
(0037493) lucaghera (reporter) 2014-12-19 04:36 |
Here are some preliminary results. I did it on MAC. a) It seems that the variable in which all the defines are stored is the variable ${_gccStdout} b) For some reason that is not yet clear to me, when CMake run the command to infer the #defines this variable is empty and the variable ${_gccOutput} contains "g++-4.9: error: -std=c++11: No such file or directory". This error does not happen if I don't set the language (i.e. project(NAME CXX)). However in that case the default language seems to be C and the code doesn't use the CXX_ARG_1 containing std=c++11. |
(0037497) Brad King (manager) 2014-12-19 08:34 |
Re 0015316:0037493: Thanks for looking into it. To debug the call to g++, just before the execute_process line add: message("'${_compilerExecutable}' '${_arg1}' '${_stdver}' '${_stdlib}' '-v' '-E' '-x' '${_lang}' '-dD' 'dummy'") This should show exactly what command is being executed. |
(0037944) Andrea Salvi (reporter) 2015-02-07 08:09 |
I can confirm this happening also in cmake 3.1.2. I'm using Xubuntu 14.04 LTS 64bit. Here is my CMakeList.txt snippet with which I enable C++11: include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() message(FATAL_ERROR "${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() 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.4" CACHE STRING "Eclipse version" FORCE) endif() I have checked how g++ is being called while building my project and the -std=c++11 argument is present. |
(0037987) Andrea Salvi (reporter) 2015-02-17 06:01 |
Ok, I think I managed to understand why this behavior happened. Initially, this is the g++ call that was used to fetch all of the compiler's properties and flags: /usr/bin/c++ -v -E -x c++ -dD dummy This way the compiler uses the C++98 standard, which is apparently the default for GCC 4.8, shipped with Ubuntu 14.04 and its derivatives. To force the compiler to use the C++11 standard, I had to prepend 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.4" CACHE STRING "Eclipse version" FORCE) endif() before the project() declaration. This way, the call to g++ became /usr/bin/c++ -std=c++11 -v -E -x c++ -dD dummy and the Eclipse project file was set with the correct properties. |
(0040514) Gregory Kramida (reporter) 2016-02-19 10:29 edited on: 2016-02-19 10:31 |
Hi all, thank you all for looking into this issue to date. Apparently, this issue is still around and is possibly causing indexer errors in Eclipse CDT (on any OS), even with the -std=c++11 manually included in the parser options. Value of __cplusplus, using the lastest CMake build, is still incorrect without using the workaround graciously provided by @Andrea Salvi. Is it possible to fix this so that the generator takes the C++ standard flags into account when querying gcc to make the CDT project file? -Thanks |
(0042692) Kitware Robot (administrator) 2016-06-10 14:29 |
Resolving issue as `moved`. This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2014-12-18 08:46 | lucaghera | New Issue | |
2014-12-18 09:04 | Brad King | Note Added: 0037479 | |
2014-12-18 09:17 | lucaghera | Note Added: 0037480 | |
2014-12-18 09:27 | Brad King | Note Added: 0037481 | |
2014-12-19 04:36 | lucaghera | Note Added: 0037493 | |
2014-12-19 08:34 | Brad King | Note Added: 0037497 | |
2015-02-07 08:09 | Andrea Salvi | Note Added: 0037944 | |
2015-02-17 06:01 | Andrea Salvi | Note Added: 0037987 | |
2016-02-19 10:29 | Gregory Kramida | Note Added: 0040514 | |
2016-02-19 10:31 | Gregory Kramida | Note Edited: 0040514 | |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042692 | |
2016-06-10 14:29 | Kitware Robot | Status | new => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:29 | Kitware Robot | Assigned To | => Kitware Robot |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |