View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0014962 | CMake | CMake | public | 2014-06-08 14:23 | 2016-06-10 14:31 | ||||
Reporter | Michael Kahane | ||||||||
Assigned To | Alex Neundorf | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | x86_64 | OS | Linux | OS Version | 14.04 | ||||
Product Version | CMake 2.8.12 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0014962: Eclipse generator does not cause -std= and -stdlib= flags to affect include path | ||||||||
Description | I'm trying to setup a C++ project in eclipse. The project is using the clang++ compiler and I'm using it in C++11 mode with libc++. To make the Eclipse generator detect the proper include paths and language I'm setting CMAKE_CXX_COMPILER_ARG1="-std=c++11 -stdlib=libc+11" on the command line but the the include paths do not appear in the generated eclipse project. I've also tried CMAKE_CXX_COMPILER_ARG1=-std=c++11\;-stdlib=libc+11 but the generator fails with an error in this case. If I use only one argument to CMAKE_CXX_COMPILER_ARG1 it works. However if I use CMAKE_CXX_COMPILER_ARG1=-std=c11 it will set the __GXX_EXPERIMENTAL_CXX0X__ flag but not the include path to libc++ (instead it will set the include paths to stdlibc++). If I use CMAKE_CXX_COMPILER_ARG1=-stblib=libc+11 it will add /usr/include/c++/v1 to the include path but not set the __GXX_EXPERIMENTAL_CXX0X__ flags. | ||||||||
Steps To Reproduce | You need a setup with clang++ and libc++. Assuming you have a c++ project in proj_dir make an adjacent build_dir. cd to the build_dir and: CC=clang CXX=clang++ cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_ARG1=-std=c++11\;-stdlib=libc++ -DCMAKE_ECLIPSE_VERSION=4.3 ../proj_dir or CC=clang CXX=clang++ cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_ARG1="-std=c++11-stdlib=libc++" -DCMAKE_ECLIPSE_VERSION=4.3 ../proj_dir | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0036132) Brad King (manager) 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 (reporter) 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 (manager) 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 (developer) 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 (reporter) 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 (reporter) 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 (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-06-08 14:23 | Michael Kahane | New Issue | |
2014-06-09 09:52 | Brad King | Note Added: 0036132 | |
2014-06-09 10:17 | Michael Kahane | Note Added: 0036133 | |
2014-06-09 10:19 | Michael Kahane | Note Edited: 0036133 | |
2014-06-09 10:20 | Brad King | Summary | Eclipse generator fails with several params to CMAKE_CXX_COMPILER_ARG1 => Eclipse generator does not cause -std= and -stdlib= flags to affect include path |
2014-06-09 10:22 | Brad King | Note Added: 0036134 | |
2014-06-09 10:44 | Alex Neundorf | Assigned To | => Alex Neundorf |
2014-06-09 10:44 | Alex Neundorf | Status | new => assigned |
2014-06-09 11:35 | Ben Boeckel | Note Added: 0036137 | |
2014-06-09 16:40 | Michael Kahane | Note Added: 0036145 | |
2014-06-09 17:00 | Michael Kahane | Note Added: 0036146 | |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042561 | |
2016-06-10 14:29 | Kitware Robot | Status | assigned => resolved |
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved |
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |