c++cmakeemacsemacs-projectile

How to override emacs-projectile default configuration for project?


I try to use emacs with projectile to configure and than build C++ CMake project. By default projectile use next configuration:

(defconst projectile--cmake-manual-command-alist
  '((:configure-command . "cmake -S . -B build")
    (:compile-command . "cmake --build build")
    (:test-command . "cmake --build build --target test")))

How can I override this settings for my project(only for my project)? Suppose I want to make something like:

(defconst projectile--cmake-manual-command-alist
  '((:configure-command . "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . -B .build")
    (:compile-command . "cmake --build .build")
    (:test-command . "cmake --build .build --target unit-tests")))

I search throw documentation but can't find some simple solution. I expect to see modification for .dir-locals.el file with some new variables. Maybe am I doing something completely wrong and I should use it in different way? Thanks in advance.


Solution

  • Have you tried put this .dir-locals.el in the root dir of your project?

    ;;; Directory Local Variables
    ;;; For more information see (info "(emacs) Directory Variables")
    
    ((c++-mode . ((projectile--cmake-manual-command-alist . ((:configure-command . "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . -B .build")
                                                        (:compile-command . "cmake --build .build")
                                                        (:test-command . "cmake --build .build --target unit-tests"))))))