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

cmake-ide-cmake-opts can't contain parameters with spaces #181

Closed
andrmuel opened this issue Oct 10, 2018 · 5 comments
Closed

cmake-ide-cmake-opts can't contain parameters with spaces #181

andrmuel opened this issue Oct 10, 2018 · 5 comments

Comments

@andrmuel
Copy link

Due to the 'split-string' in cide--run-cmake-impl, it is not possible to have a space in a parameter in cmake-ide-cmake-opts (e.g. "-DCONF_FILES=foo.conf bar.conf").

My workaround for the moment is to allow passing the parameters as lists:

(defun cide--run-cmake-impl (project-dir cmake-dir)
  "Run the CMake process for PROJECT-DIR in CMAKE-DIR."
  (when project-dir
    (let ((default-directory cmake-dir))
      (cide--message "Running cmake for src path %s in build path %s" project-dir cmake-dir)
      (apply 'start-process (append (list "cmake" "*cmake*" cmake-ide-cmake-command)
                                    (if (listp cmake-ide-cmake-opts) cmake-ide-cmake-opts (split-string cmake-ide-cmake-opts))
                                    (list "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" project-dir))))))

(defun cide--project-key ()
  "Return a unique key for a project based on the project dir and cmake options."
  (let ((project-dir (cide--locate-project-dir)))
    (when project-dir
      ;; if no project-dir, then get-project-key is called from a non cmake project dir, simply ignore
      (replace-regexp-in-string "[-/= ]" "_"  (concat (expand-file-name project-dir)
                                                      (if (listp cmake-ide-cmake-opts) (string-join cmake-ide-cmake-opts " ") cmake-ide-cmake-opts))))))

Maybe this could be added to cmake-ide?

@atilaneves
Copy link
Owner

What's the use case for having a space in the option?

@andrmuel
Copy link
Author

andrmuel commented Oct 21, 2018 via email

@atilaneves
Copy link
Owner

I looked at your original example again and -DCONF_FILES=foo.conf bar.conf won't work at all with clang. It'll be just one #define (foo.conf). I don't know about your CMake option but unless there are quotes around the space-delimited list, that won't work either.

Are you using an old version of cmake-ide? It doesn't use split-string but split-string-and-unquote. I explained the history why in my comment on issue #177

@andrmuel
Copy link
Author

andrmuel commented Oct 22, 2018 via email

@atilaneves
Copy link
Owner

Sorry, I misread your issue. I now understand what you mean.

The problem is that cmake-ide-cmake-opts should never have been a string but instead a list of strings. I didn't add that one and didn't think it through when I merged it.

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

No branches or pull requests

2 participants