;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.

(defun cmake-build-and-run ()
  "Asks for cmake target, then compiles and runs it."
  (interactive)
  (let ((target
	 (ido-completing-read "Choose build target: " (remove "" (split-string
								  (shell-command-to-string "cmake --build ./cmake-build-debug --target help | awk '{if($2 != \"all\" && $2!= \"clean\" && $2 != \"following\" && $2 != \"edit_cache\" && $2 != \"rebuild_cache\" && $2 != \"depend\" && $2 !~ /\\./){print $2}}'") "\n")))))
    (shell-command (format "cmake --build ./cmake-build-debug --target %s && ./cmake-build-debug/%s" target target))))
