I have a project I build using cmake. To build this project, I need to define several options like -DPRODUCT=amd64 -DXML_DIR=/opt/xml_database Normally, I either pass these as -D or configure them in IDEs like qtcreator and vscode. How would I define them in package cmake-ide? I feel like I need to add these to .dir-local.el but could not find an example.

Edit: I am trying to edit the variable given in the answer below and it has a type of string. I checked List Variables documentation but can't seem to make it work. In my dir_local.el

((nil . ((cmake-ide-cmake-args . 
            ("-DSOME_CMAKE1=foo_bar1" "-DSOME_CMAKE2=foo_bar2")

but this gives me errors related to type of the variable.cmake-ide-cmake-args has type of list of strings. So, how can I edit that variable? I also tried

((nil . ((cmake-ide-cmake-args . 
            (list "-DSOME_CMAKE1=foo_bar1" "-DSOME_CMAKE2=foo_bar2")

((nil . ((cmake-ide-cmake-args . 
            `("-DSOME_CMAKE1=foo_bar1" "-DSOME_CMAKE2=foo_bar2")
  • Note that it's .dir-locals.el and not .dir-local.el or dir_local.el.
    – nega
    Jul 16, 2019 at 20:59

1 Answer 1


Skimming the source of cmake-ide reveals

(defcustom cmake-ide-cmake-opts
  "The options passed to cmake when calling it.  DEPRECATED, use `cmake-ide-cmake-args' instead."
  :group 'cmake-ide
  :safe #'stringp)

(defcustom cmake-ide-cmake-args
  "The options passed to cmake when calling it."
  :group 'cmake-ide
  :type '(repeat string))

So, set cmake-ide-cmake-args via customize, a setq, as a file variable or a directory local variable.

cmake-ide-cmake-args should be a list of strings. This isn't clear in its docstring, and is currently an open issue.

So, if you want to set it via a .dir-locals.el you would do something like:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((nil . ((cmake-ide-build-dir . "/Users/nega/build/foo")
         (cmake-ide-project-dir . "/Users/nega/src/foo")
         (cmake-ide-cmake-args  . ("-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_FOO=BAR")))))

Setting it via a setq would look like

(setq cmake-ide-cmake-args '("-DCMAKE_BUILD_TYPE=Release"))
  • Can you show me how to edit this variable of type '(repeat string)? I edited the question with further info.
    – meguli
    Jul 16, 2019 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.