darcamo · 2022-03-15 13:41
darcamo · 2022-03-15 13:51
I already had a function in my Emacs configuration to compile a target using ninja, but I had to manually type the target name (and know the correct name of it). I recently started working in a C++ codebase that I'm not familiar with that has many targets. Therefore, due to this personal need I decided to query this information from CMake (using its file API) for better usability. I think it might be useful to others.
This is my first package and I'm not proficient with emacs-lisp. Therefore, the code probably needs a lot of improvements.
jjgarciaripoll · 2022-03-15 18:48
You might want to consider this software I wrote https://github.com/juanjosegarciaripoll/project-cmake
It integrated with Emacs project and covers configuration, building and testing using CMake. You can edit and save per-project CMake settings and reuse them, using a .project el file It automatically recognizes all targets via the CMake file API, allowing you to select the current one.
Added bonus: It integrates with eglot and clangd providing the right settings for your project. On Windows it allows you to choose different compiler sets.
I am working on adding also a debugging tool to select which target to open in gdb using Emacs' unified debugger interface.
darcamo · 2022-03-15 21:36
I also plug into Emacs native project infrastructure. The "more recent trend" of using Emacs native functionality as much as possible (like the vertico + orderless + marginalia, instead of a big package like helm) has working very well for me, and only a way to easily choose a target to compile/run was missing in my setup.
project-cmake seems to solve the exact same use case that I was going for, and includes a bit more functionality. Thanks, I'll check it out.