Skip to content

Instantly share code, notes, and snippets.

@scotchi
Created March 27, 2019 13:30
Show Gist options
  • Save scotchi/4fb23f059b4bc6aca53f959786454707 to your computer and use it in GitHub Desktop.
Save scotchi/4fb23f059b4bc6aca53f959786454707 to your computer and use it in GitHub Desktop.
Sets the build directory for CMake projects to be the "build" directory below where CMakeLists.txt is
(add-hook 'c++-mode-hook
(lambda ()
(if (not (boundp 'cmake-ide-build-dir))
(let* ((cmake-lists (locate-dominating-file default-directory "CMakeLists.txt"))
(cmake-build (concat cmake-lists "build")))
(if (and cmake-lists (file-exists-p cmake-build))
(progn
(setq cmake-ide-build-dir cmake-build)
(global-set-key (kbd "s-.") 'cmake-ide-compile)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment