Notes |
|
(0037479)
|
Brad King
|
2014-12-18 09:04
|
|
|
|
(0037480)
|
lucaghera
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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. |
|