Notes |
|
(0036132)
|
Brad King
|
2014-06-09 09:52
|
|
CMAKE_CXX_COMPILER_ARG1 is an internal implementation detail. The proper way to specify C++ flags is with the CXXFLAGS environment variable, or in the CMAKE_CXX_FLAGS cache entry. If the Eclipse generator does not pick things up from that then that is the real issue. |
|
|
(0036133)
|
Michael Kahane
|
2014-06-09 10:17
(edited on: 2014-06-09 10:19) |
|
Actually I have:
add_compile_options(-std=c++11 -stdlib=libc++)
in CMakeLists.txt in the project source dir and I expected the Eclipse generator to pick the options from there (shouldn't it?). Googling around I got to this page about using CMAKE_CXX_COMPILER_ARG1:
http://stackoverflow.com/questions/18358389/eclipse-indexer-proper-c11-syntax-highlighting-when-generating-projects-with-c [^]
So now I tried:
CC=clang CXX=clang++ CXXFLAGS="-std=c++11 -stdlib=libc++" cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_VERSION=4.3 ../proj_dir
It also doesn't detect C++11 (no __GXX_EXPERIMENTAL_CXX0X__) and doesn't set the include path to /usr/include/c++/v1.
So both add_compile_options(-std=c++11 -stdlib=libc++) and CXXFLAGS="-std=c++11 -stdlib=libc++" don't seem to work with the Eclipse generator.
|
|
|
(0036134)
|
Brad King
|
2014-06-09 10:22
|
|
Side note: you may be interested in some recent development in the CMake 'master' branch that adds first-class support for requesting C and C++ language-standard levels (but not yet standard library selection). Look for the CXX_STANDARD target property and the CMAKE_CXX_STANDARD variable. |
|
|
(0036137)
|
Ben Boeckel
|
2014-06-09 11:35
|
|
> add_compile_options(-std=c++11 -stdlib=libc++)
The flags given here are only used during compilation, not linking. Use the CMAKE_CXX_FLAGS for this. I imagine add_compile_options will eventually get a global-flag variant, but it doesn't exist yet. |
|
|
(0036145)
|
Michael Kahane
|
2014-06-09 16:40
|
|
Ben,
I didn't understand your comment. For linking I have in CMakeLists.txt:
target_link_libraries(proj -std=c++1y -stdlib=libc++)
But I assume that the detection of c++ standard and include paths is done via the preprocessor so the compilation options should be enough.
In any case I've tried to run:
CC=clang CXX=clang++ cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_VERSION=4.3 ../proj_dir
but it also fails to correctly detect c++11 and include paths. |
|
|
(0036146)
|
Michael Kahane
|
2014-06-09 17:00
|
|
I've checked the development version (cmake version 3.0.20140606-g7ef8d). Using:
CC=clang CXX=clang++ cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_STANDARD=11 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_VERSION=4.3 ../proj_dir
The generated Eclipse project is still for C++98 (no __GXX_EXPERIMENTAL_CXX0X__ flag and also __cplusplus is 199711L). |
|
|
(0042561)
|
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. |
|