cmake-ide icon indicating copy to clipboard operation
cmake-ide copied to clipboard

Option to specify build type

Open vikigenius opened this issue 9 years ago • 2 comments

Is there an option to specify the build option i.e Debug vs Release?

Right now i created two folders, debug and release and i manually change the cmake-ide-build-dir variable in .dir-locals.el to point to one of either debug and release, where i manually call cmake -DCMAKE_BUILD_TYPE=Release .. or cmake -DCMAKE_BUILD_TYPE=Debug .. when i make the switch from debug to release or vice-verca.

I thought about manually writing an elisp function to change the cmake-ide-cmake-command, but that doesn't sound like a good idea.

Is there a better way to do this which i am missing

vikigenius avatar Sep 28 '16 11:09 vikigenius

Not right now, no. The idea is to run cmake manually first. It's on my TODO list to enable running cmake and selecting options from emacs itself. I'd recommend just having two build dirs, one for release and another for debug and changing cmake-ide-build-dir as needed.

atilaneves avatar Sep 30 '16 08:09 atilaneves

If you don't mind having your cmake-ide-build-dir and cmake-ide-compile-command variables declared globally in your emacs config files, I wrote this little piece of code :

`(defun cmake-ide-debug-shortcut () (interactive) (setq cmake-ide-build-dir "~/PATH_TO_PROJECT/build/debug/") (setq cmake-ide-compile-command "~/PATH_TO_PROJECT/build.sh -d") (cmake-ide-compile)
) (global-set-key (kbd "C-<f6>") 'cmake-ide-debug-shortcut)

(defun cmake-ide-release-shortcut () (interactive) (setq cmake-ide-build-dir "~/PATH_TO_PROJECT/build/release/") (setq cmake-ide-compile-command "~/PATH_TO_PROJECT/build.sh -r") (cmake-ide-compile)
) (global-set-key (kbd "C-<f7>") 'cmake-ide-release-shortcut)`

And this is the bash script where you specify the cmake/make commands and the different paths for your builds :

`#!/bin/bash

if [[ $1 == "-d" ]]; then

mkdir -p build/debug
cd build/debug

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..

make -j4

elif [[ $1 == "-r" ]]; then

mkdir -p build/release
cd build/release

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../..

make -j4

fi`

This a quick and simple solution, but I'm sure there is another way to have the variables defined locally for each project.

dartzon avatar Oct 22 '16 10:10 dartzon