-
-
Notifications
You must be signed in to change notification settings - Fork 582
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 support for CMake-presets. #1656
Conversation
Not sure if this too much CMake for projectile. I guess this needs to check if json is available in a better way. Not quite sure what is the best method to do it. |
277e1b7
to
e5b77df
Compare
Ended up just relying on |
I'm okay with the proposed addition, but this has to be documented well if we expect people to make good use of it. I'm also wondering if there might be a case when someone would prefer the old behaviour (e.g. should we have a defcustom for it). |
e5b77df
to
0e84a16
Compare
Yes. Where do you want me to add the documentation? Somewhere under projects.adoc? Do you mean a defcustom for specifying the configuration-cmd (ie a projectile-cmake-project-configure-function), or one to toggle preset integration on and off? |
I tried adding a defcustom to opt-in to preset-configuration, as well as improving the docstrings and naming. It seems that the snapshot CI is failing due to some other long docstring. |
CMake just got support for build and test presets in |
Not at all.
On Mon, 29 Mar 2021 at 8:28, jehelset ***@***.***> wrote:
CMake just got support for build and test presets in 3.20 (
https://cmake.org/cmake/help/latest/release/3.20.html#presets), do you
mind if I add that also here?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1656 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAZLSRCS4KNCUJJ3DE37FTTGAMZTANCNFSM4YX4JR3Q>
.
--
Best Regards,
Bozhidar Batsov
|
I will squash / tidy the commits afterwards. It seemed to mess with the change-requests. I tried adding preset-support for compile and test commands. |
54f4de5
to
30a4a25
Compare
30a4a25
to
b984a41
Compare
b984a41
to
a10be26
Compare
projectile.el
Outdated
;;;; Constant signifying opting out of CMake preset commands. | ||
(defconst projectile--cmake-no-preset "*no preset*") | ||
|
||
(defun projectile--cmake-version() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's idiomatic to have a space between the function name and its param list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
projectile.el
Outdated
'((:configure-command . (3 19)) | ||
(:compile-command . (3 20)) | ||
(:test-command . (3 20)))) | ||
(defun projectile--cmake-command-presets-supported(command-type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I normally add blank lines around function defs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, isn't it easier to just set 3.20 as the minimum version for everything instead of having it so granular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the blank lines.
I think the combination of how nice presets are, and CMake often being installed via the system package manager on non-rolling distros justifies the level of granularity. The configuration-preset is by far the most valuable. See f.ex: https://packages.debian.org/sid/cmake (unstable is still on 3.18).
I can remove it if it's too much, but I would be hard pressed to make a choice between setting minimum version to 3.19 and dropping support for compile and test-commands or setting the minimum version to 3.20!
Either there or under "Configuration".
I was thinking of something that toggles the new functionality globally. (mostly so people can easily opt out of it, if they run into any issues) |
I previously added the |
CHANGELOG.md
Outdated
* Add `projectile-update-project-type-function` for updating the properties of existing project types | ||
* [#1656](https://github.com/bbatsov/projectile/pull/1656) Add support for CMake configure, build and test presets. Enabled by setting `projectile-cmake-presets` to non-nil, disabled by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot :
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
CHANGELOG.md
Outdated
|
||
### Changes | ||
|
||
* Add `project` param to `projectile-generate-process-name`. | ||
* [#1608](https://github.com/bbatsov/projectile/pull/1608): Use rebar3 build system by default for Erlang projects. | ||
* Rename `projectile-project-root-files-functions` to `projectile-project-root-functions`. | ||
* [#1647](https://github.com/bbatsov/projectile/issues/1647): Use "-B" in the mvn commands to avoid ANSI coloring clutter in the compile buffer | ||
* [#1656](https://github.com/bbatsov/projectile/pull/1656) CMake compilation-dir removed to accomodate preset support, commands adjusted to run from project-root, with "build" still being the default build-directory. The non-preset test-command now uses "cmake" with "--target test" instead of "ctest". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
It seems you'll also have to rebase on top of |
ec258d4
to
12cbaec
Compare
Squashed and rebased. |
Hm, I thought so. |
I fetched from wrong remote... Sorry, sec. |
12cbaec
to
53a7100
Compare
There we go. :P |
Introduce a `projectile--cmake-command`, for CMake projects parametrized on command-type, and route configure, build and test commands for cmake projects through this. This command ensures that presets for the given command-type is supported by the installed version of CMake, that `json-parse-buffer` is available, that the user has opted in to preset support through the `projectile-enable-cmake-presets` custom, and that there is at least one preset available for the given command type. If all these conditions hold it parses the preset files and prompts the user to select a preset, or to opt-out of preset configuration, and creates a manual or preset command based on the users selection. Else it will revert to manual configuration.
53a7100
to
dc09e10
Compare
Thanks! |
Support configuring, building and testing CMake projects using cmake-presets.
Introduces
projectile--cmake-command
for CMake projects which computes a command based on the command-type. If CMake preset support is enabled through theprojectile-enable-cmake-presets
custom, and if presets are supported for the command-type by CMake, CMake preset-files are parsed and a completing-read is done on the names of the command presets along with an option for manual configuration. If not supported, or there are no presets specified for the given command-type, it reverts to manual configuration as before. Configure, build and test commands for CMake projects are all implemented in terms of this command.To support presets the compilation-dir for CMake-projects was removed, and the manual commands were adjusted to support being run from the project-root.
Needs
json-parse-buffer
to be available, else falls back to manual configuration.Tested manually with CMake 3.19 (presets supported), and 3.18 (not supported) only, and emacs 27.1 (json-parse-buffer available) and emacs 26.3 (json-parse-buffer unavailable). Not sure how to to project-type specific testing. Initially implemented at jehelset/projectile-cmake.
Before submitting a PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):
eldev test
)M-x checkdoc
warningsThanks!