Skip to content

Commit

Permalink
Add package command for CMake (#1870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jehelset authored Nov 29, 2023
1 parent 9446ea9 commit 9bb74c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

* [#1870](https://github.com/bbatsov/projectile/pull/1870): Add package command for CMake projects.

## 2.8.0 (2023-10-13)

### New features
Expand Down
12 changes: 10 additions & 2 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,7 @@ it acts on the current project."
'((:configure-command . (3 19))
(:compile-command . (3 20))
(:test-command . (3 20))
(:package-command . (3 19))
(:install-command . (3 20))))

(defun projectile--cmake-command-presets-supported (command-type)
Expand All @@ -3081,6 +3082,7 @@ it acts on the current project."
'((:configure-command . "configurePresets")
(:compile-command . "buildPresets")
(:test-command . "testPresets")
(:package-command . "packagePresets")
(:install-command . "buildPresets")))

(defun projectile--cmake-command-preset-array-id (command-type)
Expand All @@ -3095,7 +3097,7 @@ it acts on the current project."
(gethash (projectile--cmake-command-preset-array-id command-type) preset))))

(defun projectile--cmake-command-presets (filename command-type)
"Get CMake COMMAND-TYPE presets from FILENAME. Follows included files"
"Get CMake COMMAND-TYPE presets from FILENAME. Follows included files."
(when-let ((preset (projectile--cmake-read-preset (projectile-expand-root filename))))
(append
(projectile--cmake-command-presets-shallow filename command-type)
Expand Down Expand Up @@ -3157,6 +3159,7 @@ select a name of a command preset, or opt a manual command by selecting
'((:configure-command . "cmake -S . -B build")
(:compile-command . "cmake --build build")
(:test-command . "cmake --build build --target test")
(:package-command . "cmake --build build --target package")
(:install-command . "cmake --build build --target install")))

(defun projectile--cmake-manual-command (command-type)
Expand All @@ -3167,6 +3170,7 @@ select a name of a command preset, or opt a manual command by selecting
'((:configure-command . "cmake . --preset %s")
(:compile-command . "cmake --build --preset %s")
(:test-command . "ctest --preset %s")
(:package-command . "cpack --preset %s")
(:install-command . "cmake --build --preset %s --target install")))

(defun projectile--cmake-preset-command (command-type preset)
Expand Down Expand Up @@ -3205,6 +3209,10 @@ a manual COMMAND-TYPE command is created with
"CMake install command."
(projectile--cmake-command :install-command))

(defun projectile--cmake-package-command ()
"CMake package command."
(projectile--cmake-command :package-command))

;;; Project type registration
;;
;; Project type detection happens in a reverse order with respect to
Expand Down Expand Up @@ -3289,7 +3297,7 @@ a manual COMMAND-TYPE command is created with
:compile #'projectile--cmake-compile-command
:test #'projectile--cmake-test-command
:install #'projectile--cmake-install-command
:package "cmake --build build --target package")
:package #'projectile--cmake-package-command)
;; go-task/task
(projectile-register-project-type 'go-task '("Taskfile.yml")
:project-file "Taskfile.yml"
Expand Down

0 comments on commit 9bb74c8

Please sign in to comment.