Closed dlyr closed 4 years ago
Nothing like people using something with varied usage patterns for finding rough spots. :)
I was going to say this should be easy to add, and give a few steps you could use for a PR, but it would have taken about as long to explain as just do it, so I did.
But fear not, you still have work to do. :wink: I only wrote the facility for custom build dir naming, you will still have to write a function to do so and incorporate your tags etc. See this README section for how the function should look. You should be able to set your function with customize or setq
.
I did a fairly cursory test of alternate build roots, but I didn't test in Windows with drive letters or anything particularly unusual. If there are any issues, let me know of course (a PR fixing them would be great too...).
Thanks for your quick update.
The custom build dir name function works well. But the out of source build dir doesn't.
It's not working for me, so I hope I do things well. I think the bug comes from the fact that
cmake-build-clear-cache-and-configure
set (default-directory (cmake-build--get-build-dir))
and if this directory is not a subdir of project-root, subsequent calls to projectile-project-root
falls to identify the current project root
I have a workaround, but I don't think it works with multiple opened project.
It's to set the cmake-build-project-root
to (cmake-build--project-root)
before changing directory, i.e.
around line 380
(defun cmake-build-clear-cache-and-configure ()
(interactive)
(unless (file-exists-p (cmake-build--get-build-dir))
(make-directory (cmake-build--get-build-dir)))
(let* ((cmake-build-project-root (cmake-build--project-root))
(default-directory (cmake-build--get-build-dir))
(buffer-name (cmake-build--build-buffer-name))
Another way is to have a map of project-key / project-dir as found in cmake-ide but it can creates huge modifications.
Another option might be to call cmake with -S and -B options, so no need to change directory. I'm trying currently but still not working.
Check this branch https://github.com/dlyr/cmake-build.el/tree/cmake-explicit-build-dir I'm clearly not sure it's the right way todo ...
Whoops, I added a macro for this but forgot to apply it to this (and some others). Apparently it worked while testing because I had forced the project root, since it's annoying to switch windows while editing the elisp. ;)
(Let me know if the above commit doesn't fix it, or if I missed anything else.)
Works perfectly ! FYI I use
(defun my-dir-name-function (project-root profile)
"Return the directory name to run CMake in."
(replace-regexp-in-string "[-/= ]" "_" (concat (expand-file-name project-root)
(if (fboundp 'magit-get-current-branch) (magit-get-current-branch) "")
"."
profile))
)
(setq cmake-build-dir-name-function 'my-dir-name-function)
With an external build pool.
I do not see in the README where cmake-build-dir-name-function
but I figured it out pretty well.
Next things (I hope I can do it) is to work on the split window function (sometimes emacs hasn't sufficient space to split) and also on the mode of the compilation buffer so that search error works (it may be a pb on my side)/
I usually set my build directory on another hard drive (ssd) I do not figure out how to do that with
cmake-build.el
any idea ? Also I want to add the current git branch name to the build dir (like the release type), maybe this feature is not used by alot of people, but I work on project where I had to switch and build different git branches frequently. I'm not sure on how to add theses features, but I can take some time to try it if PR are welcome and if I had some hints on how to go in the right direction.