Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake-ide to lang/c-c++ layer #9432

Closed
wants to merge 2 commits into from
Closed

Add cmake-ide to lang/c-c++ layer #9432

wants to merge 2 commits into from

Conversation

myrgy
Copy link
Contributor

@myrgy myrgy commented Aug 14, 2017

rebased to develop version of #7187
preparing stage for RTags(pull request #2834). (issue #2327)

Copy link
Contributor

@robbyoconnor robbyoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robbyoconnor
Copy link
Contributor

Your README has issues.

@robbyoconnor
Copy link
Contributor

The fix is literally to just change Features to Features: -- and then you should be green 💯

@myrgy
Copy link
Contributor Author

myrgy commented Aug 14, 2017

@robbyoconnor , thanks a lot! Now it's all green 👍

@myrgy myrgy mentioned this pull request Aug 14, 2017
@myrgy
Copy link
Contributor Author

myrgy commented Aug 21, 2017

@robbyoconnor , do we need to perform some extra steps to merge this PR?

@robbyoconnor
Copy link
Contributor

@myrgy You can't merge it -- somebody who has merge rights -- in this @syl20bnr or one of the collaborators. You can simply cherry-pick this commit restart spacemacs and you'll have it.

@myrgy
Copy link
Contributor Author

myrgy commented Aug 21, 2017

@robbyoconnor , I see. Thank you for your assistance.

@robbyoconnor
Copy link
Contributor

robbyoconnor commented Aug 21, 2017 via email

(spacemacs/declare-prefix-for-mode mode "mg" "goto")
(spacemacs/declare-prefix-for-mode mode "mp" "project/build system")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the prefix be "project", not "project/build system"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the above

@@ -112,6 +115,8 @@ doesn't complain about missing header files.
| ~SPC m g A~ | open matching file in another window (e.g. switch between .cpp and .h) |
| ~SPC m D~ | disaster: disassemble c/c++ code |
| ~SPC m r~ | srefactor: refactor thing at point. |
| ~SPC m p~ | Project / Build system management |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add the key bindings for cmake-ide functions. Also SPC m p is a prefix, not a function, so it doesn't need a key binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're not actually documenting any of the keybindings. This is rather lazy.

Copy link
Contributor

@robbyoconnor robbyoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. Documentation needs work.

"pc" 'cmake-ide-run-cmake
"pC" 'cmake-ide-maybe-run-cmake
"pd" 'cmake-ide-delete-file))))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be documented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(spacemacs/declare-prefix-for-mode mode "mg" "goto")
(spacemacs/declare-prefix-for-mode mode "mp" "project/build system")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the above

@@ -112,6 +115,8 @@ doesn't complain about missing header files.
| ~SPC m g A~ | open matching file in another window (e.g. switch between .cpp and .h) |
| ~SPC m D~ | disaster: disassemble c/c++ code |
| ~SPC m r~ | srefactor: refactor thing at point. |
| ~SPC m p~ | Project / Build system management |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're not actually documenting any of the keybindings. This is rather lazy.

@myrgy
Copy link
Contributor Author

myrgy commented Aug 23, 2017

@beta1440 , @robbyoconnor , thanks for review.
Fixed.

Copy link
Contributor

@robbyoconnor robbyoconnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 ✔️ ✅

"pc" 'cmake-ide-run-cmake
"pC" 'cmake-ide-maybe-run-cmake
"pd" 'cmake-ide-delete-file))))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robbyoconnor
Copy link
Contributor

Note to collaborators and @syl20bnr : I didn't run this -- I simply checked if it looked okay and had supporting documentation.

@myrgy
Copy link
Contributor Author

myrgy commented Aug 24, 2017

@syl20bnr, plz review this PR. I hope it's ready to merge.

Note: I'm using it in my every day work ( + rtags)

@syl20bnr syl20bnr self-assigned this Aug 28, 2017
@syl20bnr
Copy link
Owner

Thank you ! 👍
Cherry-picked into develop branch, you can safely delete your branch.

@syl20bnr syl20bnr closed this Aug 28, 2017
@syl20bnr syl20bnr removed the Merged label Aug 28, 2017
@myrgy myrgy deleted the feature/cmake-ide-integration branch August 28, 2017 06:29
@andyleejordan
Copy link
Contributor

The cmake-ide integration probably shouldn't be on automatically, it makes browsing C++ files really slow. I'm running the develop branch, and now when opening any header, I'm stuck waiting for all this work to finish:

cmake-ide [Thu Oct  5 14:45:51 2017]: Finished running CMake
cmake-ide [Thu Oct  5 14:45:51 2017]: Converting JSON CDB /tmp/cmake66100fkt/compile_commands.json to IDB
cmake-ide [Thu Oct  5 14:45:51 2017]: Setting flags for file /home/andschwa/src/mesos-master/include/mesos/http.hpp
Working...
Finding buffer http.cpp...
Finding ./http.cpp...
Finding /usr/include/http.cpp...
Finding buffer http.cpp...
Finding /usr/local/include/./http.cpp...
Finding /usr/local/include/elfio/http.cpp...
Finding /usr/local/include/event2/http.cpp...
Finding /usr/local/include/mesos/http.cpp...
Finding /usr/local/include/process/http.cpp...
Finding /usr/local/include/stout/http.cpp...
cmake-ide [Thu Oct  5 14:45:51 2017]: Searching for source file including /home/andschwa/src/mesos-master/include/mesos/http.hpp
cmake-ide [Thu Oct  5 14:45:54 2017]: Could not find suitable src file for /home/andschwa/src/mesos-master/include/mesos/http.hpp, using all compiler flags
Quit emacsclient request

Is there any way to speed this up by default, or disable it? It's taking literally sometimes minutes to open a header file. The Quit is where I hit C-g because I couldn't wait any longer.

@andyleejordan
Copy link
Contributor

This seems to affect more than just C and C++ files. I went to open the latest C/C++ layer docs, and waited for all this work to finish:

cmake-ide [Thu Oct  5 14:48:41 2017]: Setting flags for file /usr/include/features.h
Working...
Finding buffer features.c...
Finding buffer features.cc...
Finding buffer features.C...
Finding buffer features.CC...
Finding buffer features.cxx...
Finding buffer features.cpp...
Finding buffer features.m...
Finding ./features.c...
Finding ./features.cc...
Finding ./features.C...
Finding ./features.CC...
Finding ./features.cxx...
Finding ./features.cpp...
Finding ./features.m...
Finding /usr/include/features.c...
Finding /usr/include/features.cc...
Finding /usr/include/features.C...
Finding /usr/include/features.CC...
Finding /usr/include/features.cxx...
Finding /usr/include/features.cpp...
Finding /usr/include/features.m...
Finding buffer features.c...
Finding buffer features.cc...
Finding buffer features.C...
Finding buffer features.CC...
Finding buffer features.cxx...
Finding buffer features.cpp...
Finding buffer features.m...
Finding /usr/local/include/./features.c...
Finding /usr/local/include/./features.cc...
Finding /usr/local/include/./features.C...
Finding /usr/local/include/./features.CC...
Finding /usr/local/include/./features.cxx...
Finding /usr/local/include/./features.cpp...
Finding /usr/local/include/./features.m...
Finding /usr/local/include/elfio/features.c...
Finding /usr/local/include/elfio/features.cc...
Finding /usr/local/include/elfio/features.C...
Finding /usr/local/include/elfio/features.CC...
Finding /usr/local/include/elfio/features.cxx...
Finding /usr/local/include/elfio/features.cpp...
Finding /usr/local/include/elfio/features.m...
Finding /usr/local/include/event2/features.c...
Finding /usr/local/include/event2/features.cc...
Finding /usr/local/include/event2/features.C...
Finding /usr/local/include/event2/features.CC...
Finding /usr/local/include/event2/features.cxx...
Finding /usr/local/include/event2/features.cpp...
Finding /usr/local/include/event2/features.m...
Finding /usr/local/include/mesos/features.c...
Finding /usr/local/include/mesos/features.cc...
Finding /usr/local/include/mesos/features.C...
Finding /usr/local/include/mesos/features.CC...
Finding /usr/local/include/mesos/features.cxx...
Finding /usr/local/include/mesos/features.cpp...
Finding /usr/local/include/mesos/features.m...
Finding /usr/local/include/process/features.c...
Finding /usr/local/include/process/features.cc...
Finding /usr/local/include/process/features.C...
Finding /usr/local/include/process/features.CC...
Finding /usr/local/include/process/features.cxx...
Finding /usr/local/include/process/features.cpp...
Finding /usr/local/include/process/features.m...
Finding /usr/local/include/stout/features.c...
Finding /usr/local/include/stout/features.cc...
Finding /usr/local/include/stout/features.C...
Finding /usr/local/include/stout/features.CC...
Finding /usr/local/include/stout/features.cxx...
Finding /usr/local/include/stout/features.cpp...
Finding /usr/local/include/stout/features.m...
cmake-ide [Thu Oct  5 14:48:41 2017]: Searching for source file including /usr/include/features.h
cmake-ide [Thu Oct  5 14:48:41 2017]: Could not find suitable src file for /usr/include/features.h, using all compiler flags
Note: c-basic-offset, evil-shift-width adjusted to 2
cmake-ide [Thu Oct  5 14:48:45 2017]: Setting flags for file /usr/include/sys/cdefs.h
Working...
Finding buffer cdefs.c...
Finding buffer cdefs.cc...
Finding buffer cdefs.C...
Finding buffer cdefs.CC...
Finding buffer cdefs.cxx...
Finding buffer cdefs.cpp...
Finding buffer cdefs.m...
Finding ./cdefs.c...
Finding ./cdefs.cc...
Finding ./cdefs.C...
Finding ./cdefs.CC...
Finding ./cdefs.cxx...
Finding ./cdefs.cpp...
Finding ./cdefs.m...
Finding /usr/include/cdefs.c...
Finding /usr/include/cdefs.cc...
Finding /usr/include/cdefs.C...
Finding /usr/include/cdefs.CC...
Finding /usr/include/cdefs.cxx...
Finding /usr/include/cdefs.cpp...
Finding /usr/include/cdefs.m...
Finding buffer cdefs.c...
Finding buffer cdefs.cc...
Finding buffer cdefs.C...
Finding buffer cdefs.CC...
Finding buffer cdefs.cxx...
Finding buffer cdefs.cpp...
Finding buffer cdefs.m...
Finding /usr/local/include/./cdefs.c...
Finding /usr/local/include/./cdefs.cc...
Finding /usr/local/include/./cdefs.C...
Finding /usr/local/include/./cdefs.CC...
Finding /usr/local/include/./cdefs.cxx...
Finding /usr/local/include/./cdefs.cpp...
Finding /usr/local/include/./cdefs.m...
Finding /usr/local/include/elfio/cdefs.c...
Finding /usr/local/include/elfio/cdefs.cc...
Finding /usr/local/include/elfio/cdefs.C...
Finding /usr/local/include/elfio/cdefs.CC...
Finding /usr/local/include/elfio/cdefs.cxx...
Finding /usr/local/include/elfio/cdefs.cpp...
Finding /usr/local/include/elfio/cdefs.m...
Finding /usr/local/include/event2/cdefs.c...
Finding /usr/local/include/event2/cdefs.cc...
Finding /usr/local/include/event2/cdefs.C...
Finding /usr/local/include/event2/cdefs.CC...
Finding /usr/local/include/event2/cdefs.cxx...
Finding /usr/local/include/event2/cdefs.cpp...
Finding /usr/local/include/event2/cdefs.m...
Finding /usr/local/include/mesos/cdefs.c...
Finding /usr/local/include/mesos/cdefs.cc...
Finding /usr/local/include/mesos/cdefs.C...
Finding /usr/local/include/mesos/cdefs.CC...
Finding /usr/local/include/mesos/cdefs.cxx...
Finding /usr/local/include/mesos/cdefs.cpp...
Finding /usr/local/include/mesos/cdefs.m...
Finding /usr/local/include/process/cdefs.c...
Finding /usr/local/include/process/cdefs.cc...
Finding /usr/local/include/process/cdefs.C...
Finding /usr/local/include/process/cdefs.CC...
Finding /usr/local/include/process/cdefs.cxx...
Finding /usr/local/include/process/cdefs.cpp...
Finding /usr/local/include/process/cdefs.m...
Finding /usr/local/include/stout/cdefs.c...
Finding /usr/local/include/stout/cdefs.cc...
Finding /usr/local/include/stout/cdefs.C...
Finding /usr/local/include/stout/cdefs.CC...
Finding /usr/local/include/stout/cdefs.cxx...
Finding /usr/local/include/stout/cdefs.cpp...
Finding /usr/local/include/stout/cdefs.m...
cmake-ide [Thu Oct  5 14:48:45 2017]: Searching for source file including /usr/include/sys/cdefs.h
cmake-ide [Thu Oct  5 14:48:46 2017]: Could not find suitable src file for /usr/include/sys/cdefs.h, using all compiler flags
cmake-ide [Thu Oct  5 14:48:55 2017]: Setting flags for file /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h
Working...
Finding buffer c++config.c...
Finding buffer c++config.cc...
Finding buffer c++config.C...
Finding buffer c++config.CC...
Finding buffer c++config.cxx...
Finding buffer c++config.cpp...
Finding buffer c++config.m...
Finding ./c++config.c...
Finding ./c++config.cc...
Finding ./c++config.C...
Finding ./c++config.CC...
Finding ./c++config.cxx...
Finding ./c++config.cpp...
Finding ./c++config.m...
Finding /usr/include/c++config.c...
Finding /usr/include/c++config.cc...
Finding /usr/include/c++config.C...
Finding /usr/include/c++config.CC...
Finding /usr/include/c++config.cxx...
Finding /usr/include/c++config.cpp...
Finding /usr/include/c++config.m...
Finding buffer c++config.c...
Finding buffer c++config.cc...
Finding buffer c++config.C...
Finding buffer c++config.CC...
Finding buffer c++config.cxx...
Finding buffer c++config.cpp...
Finding buffer c++config.m...
Finding /usr/local/include/./c++config.c...
Finding /usr/local/include/./c++config.cc...
Finding /usr/local/include/./c++config.C...
Finding /usr/local/include/./c++config.CC...
Finding /usr/local/include/./c++config.cxx...
Finding /usr/local/include/./c++config.cpp...
Finding /usr/local/include/./c++config.m...
Finding /usr/local/include/elfio/c++config.c...
Finding /usr/local/include/elfio/c++config.cc...
Finding /usr/local/include/elfio/c++config.C...
Finding /usr/local/include/elfio/c++config.CC...
Finding /usr/local/include/elfio/c++config.cxx...
Finding /usr/local/include/elfio/c++config.cpp...
Finding /usr/local/include/elfio/c++config.m...
Finding /usr/local/include/event2/c++config.c...
Finding /usr/local/include/event2/c++config.cc...
Finding /usr/local/include/event2/c++config.C...
Finding /usr/local/include/event2/c++config.CC...
Finding /usr/local/include/event2/c++config.cxx...
Finding /usr/local/include/event2/c++config.cpp...
Finding /usr/local/include/event2/c++config.m...
Finding /usr/local/include/mesos/c++config.c...
Finding /usr/local/include/mesos/c++config.cc...
Finding /usr/local/include/mesos/c++config.C...
Finding /usr/local/include/mesos/c++config.CC...
Finding /usr/local/include/mesos/c++config.cxx...
Finding /usr/local/include/mesos/c++config.cpp...
Finding /usr/local/include/mesos/c++config.m...
Finding /usr/local/include/process/c++config.c...
Finding /usr/local/include/process/c++config.cc...
Finding /usr/local/include/process/c++config.C...
Finding /usr/local/include/process/c++config.CC...
Finding /usr/local/include/process/c++config.cxx...
Finding /usr/local/include/process/c++config.cpp...
Finding /usr/local/include/process/c++config.m...
Finding /usr/local/include/stout/c++config.c...
Finding /usr/local/include/stout/c++config.cc...
Finding /usr/local/include/stout/c++config.C...
Finding /usr/local/include/stout/c++config.CC...
Finding /usr/local/include/stout/c++config.cxx...
Finding /usr/local/include/stout/c++config.cpp...
Finding /usr/local/include/stout/c++config.m...
cmake-ide [Thu Oct  5 14:48:55 2017]: Searching for source file including /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h
cmake-ide [Thu Oct  5 14:48:58 2017]: Could not find suitable src file for /usr/include/c++/4.8.2/x86_64-redhat-linux/bits/c++config.h, using all compiler flags

@myrgy
Copy link
Contributor Author

myrgy commented Oct 7, 2017

seems like it worth to add variable to be able to enable/disable cmake-ide
about slow opening - there is a bug in cmake-ide
atilaneves/cmake-ide#59

@andyleejordan
Copy link
Contributor

Thanks @myrgy, that helped!

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 11, 2017

@andschwa how did you fixed it? I am having the same problem, spacemacs is unusably slow.

Also, if this is broken, why is it enabled by default?

@myrgy
Copy link
Contributor Author

myrgy commented Oct 11, 2017

@gnzlbg , I think it was

(setq cmake-ide-header-search-other-file nil)
(setq cmake-ide-header-search-first-including nil)

I'm unable to reproduce that issue - for my projects it works pretty fast.

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 11, 2017

I'm unable to reproduce that issue - for my projects it works pretty fast.

Are they header-only projects? How big are they?

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 11, 2017

(setq cmake-ide-header-search-other-file nil)
(setq cmake-ide-header-search-first-including nil)

I've tried this and now cmake-ide goes from 10-20s to 4-5s to open header files, still pretty slow.

@andyleejordan
Copy link
Contributor

andyleejordan commented Oct 13, 2017

I'm sorry, but I think this change needs to be reverted. The cmake-ide package is simply not usable out-of-the-box. Heck, it's not really even usable after configuration. If you open a header (and come on, every C++ project has headers) you run into this year and a half old issue.

Spacemacs is supposed to "just work", and turning on cmake-ide by default does not. If you have a C++ project that does not use CMake, you're instructed to start setting up a .dir-locals.el file for the project. The user shouldn't have to do this to open any arbitrary C++ file.

For reference, I can't get cmake-ide to behave with any headers in Apache Mesos, even when using CMake (and with all of the package's variables setup). It takes multiple seconds to open header files (even with the above "search other files" options turned off), and breaks Flycheck:

Suspicious state from syntax checker c/c++-clang: Flycheck checker c/c++-clang returned non-zero exit code 126, but its output contained no errors: 
Try installing a more recent version of c/c++-clang, and please open a bug report if the issue persists in the latest release.  Thanks!

I've gone back and tested the current released version of Spacemacs with this project, and opening all my source and headers is instantaneous, as it should be. But it's not the case int he develop branch.

Edit: believe me, if we could get cmake-ide to work out-of-the-box, it'd be great, and I'd love to have it as an avid CMake user.

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 14, 2017

Maybe we can just add a way to easily toggle it on-off, or to easily configure whether you can turn it on/off by default.

I like using cmake-ide for classic C++ projects where each header has the implementation file next to it, but on the other hand it is currently not worth it to use it on header only projects: emacs becomes very slow, and for little gain since cmake-ide cannot find the flags it needs anyways.

@myrgy myrgy mentioned this pull request Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants